Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8235577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:51:29+00:00 2026-06-07T18:51:29+00:00

I am working on python plugins.I used QTreeWidget to list items. [listing in qtreewidget][1]

  • 0

I am working on python plugins.I used QTreeWidget to list items.
[listing in qtreewidget][1] this link helped me a lot.

My code is:

valestimate=QTreeWidgetItem(str(parent_name))
for row in c.fetchall():
         strval=QTreeWidgetItem(unicode(row[0])) 
         valestimate.addChild(strval)
         self.treeWidget.addTopLevelItem((valestimate))

parent_name is name of my parent in QTreeWidget.
EX: ‘ACO_233’
But output is :

![enter image description here][2]

If i set columncount as more then one then it is shown as:

![enter image description here][3]

How do i list full string as parent in Qtreewidget??
following this link [single character in qtreewidget][4] ..inserttoplevelitem takes list as parameter..But if i want to make any item as parent ,we cannot add list to qtreewidget type item. How do i do it??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:51:31+00:00Added an answer on June 7, 2026 at 6:51 pm

    Check the documentation:

     QTreeWidgetItem.__init__ (self, QStringList strings, int type = TreeWidgetItem.Type)
    

    Constructs a tree widget item of the specified type. The item must be
    inserted into a tree widget. The given list of strings will be set as
    the item text for each column in the item.

    QTreeWidgetItem expects a list of strings to fill in columns. When you do QTreeWidgetItem(str(parent_name)) it interprets the string parent_name as a list of characters (which is what a string is) and puts every character in a column. Instead you should be doing:

    valestimate = QTreeWidgetItem([parent_name])
    

    This will give you a single column item with parent_name as the value in that column.

    (By the way, str() or unicode() is not a good way to convert things around. You should use .encode to convert unicode into str or .decode for vice versa.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with python plugins.I used list to store some values as below:
I am working on python plugins.I used PyQt4 Designer. I want to list query
I am working on python plugins.I designed my form using pyqt4 designer. I used
I am working with Python plugins. I have my list called station_list ,to which
I am working on python plugins.I used PYQT4 designer for the forms. I am
I am working with python plugins for qgis .I developed the plugin same as
I'm working in Python for the first time and I've used Mechanize to search
I am working with python plugins for qgis.I am using python2.5 and pyqt4 designer.I
I am working with python plugins for QGIS . I am done with my
I am working with python plugins for QGIS.I am using python2.5 and pyqt4 .My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.