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 450105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:50:09+00:00 2026-05-12T21:50:09+00:00

I trying to do a Qtreewidget to attend a customer design suggestion. I am

  • 0

I trying to do a Qtreewidget to attend a customer design suggestion. I am coding it on QtPython. I did a first try using Qt Designer, then generated the code. But when I try to run it, an error comes out:

self.centralwidget.setSortingEnabled(__sortingEnabled)
AttributeError: setSortingEnabled

I googled around, but didn’t find any solution for this problem, except some suggestion just to simply delete the lines in the code that results in the compiling error. But it didn’t really help, because if you do so, it triggers more error, just like that:

self.treeWidget.topLevelItem(0).child(1).setText(0, QtGui.QApplication.translate("MainWindow", "Item Name", None, QtGui.QApplication.UnicodeUTF8))
AttributeError: 'NoneType' object has no attribute 'setText'

Here is my current code to generate a nice simple QtreeWidget/View:

#//==========================//#
def color_setupUi(self, MainWindow,phrase):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.eqpt_centralwdg(MainWindow)
self.eqpt_retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
#//==========================//#
def eqpt_centralwdg(self,MainWindow):
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")

self.colorTreeWidget = QtGui.QTreeWidget(self.centralwidget)
self.colorTreeWidget.setGeometry(QtCore.QRect(60, 60, 191, 141))
self.colorTreeWidget.setObjectName("colorTreeWidget")

item = QtGui.QTreeWidgetItem(self.colorTreeWidget)
item = QtGui.QTreeWidgetItem(self.colorTreeWidget)

self.centralwidget.setSortingEnabled(__sortingEnabled)
MainWindow.setCentralWidget(self.centralwidget)
#//==========================//#
def eqpt_retranslateUi(self, MainWindow):

MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)

self.colorTreeWidget.headerItem().setText(0, QtGui.QApplication.translate("MainWindow", "color", None, QtGui.QApplication.UnicodeUTF8)
__sortingEnabled = self.colorTreeWidget.isSortingEnabled()
self.colorTreeWidget.setSortingEnabled(False)
self.colorTreeWidget.topLevelItem(0).setText(0, QtGui.QApplication.translate("MainWindow", "Yellow", None, QtGui.QApplication.UnicodeUTF8)
self.colorTreeWidget.topLevelItem(1).setText(0, QtGui.QApplication.translate("MainWindow", "Blue", None, QtGui.QApplication.UnicodeUTF8)
self.colorTreeWidget.setSortingEnabled(__sortingEnabled)
#//==========================//#

All other object I needed to implement on Qt using Designer and a little bit of code has worked fine so far, e.g. inputLine, comboBox, TabWidget. I just got stuck with this TreeWidget error.

Any hints or suggestion are highly appreciated and welcome.

  • 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-05-12T21:50:10+00:00Added an answer on May 12, 2026 at 9:50 pm

    I’m assuming the code you posted is what you got when you ran your UI file through pyuic4. I found the PyQt UI compiler to be buggy sometimes. All you can do is fix the output manually and complain to the vendor.

    In your case, the line

    self.centralwidget.setSortingEnabled(__sortingEnabled) 
    

    should read

    self.colorTreeWidget.setSortingEnabled(__sortingEnabled) 
    

    I don’t understand where the AttributeError: 'NoneType' object has no attribute 'setText' comes from. You’re not referencing self.treeWidget.topLevelItem(0) in the code below.

    Since the UI doesn’t seem too complex yet, it might be worth it to start again from scratch in the QT Designer. Try to avoid cutting and pasting controls, so as not to confuse the Designer / pyuic4. Good luck!

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

Sidebar

Related Questions

i'm trying to design interface like this one http://www.softpedia.com/screenshots/FlashFXP_2.png i'm using the QT design
Trying to build out an exception if move.UserId does not equal currentUserId then Redirect
Trying to install the php-rsync module using pecl and I'm receiving the following errors:
Trying to insert values with Unicode Chars into a MySQL-database using Delphi 2010 and
Trying to get along with Sphinx/Thinking Sphinx for the first time. I've got my
trying to instantiate a Query in SubSonic using the below method (as it apparently
I'm trying to get QTreeWidget working exactly similar to this one. In python! I
Trying to deploy a Django 1.4 project using mod_wsgi and virtualenv, i'm running into
Trying to add a column with a custom attribute to the admin customer grid
Trying out PDO for the first time. $dbh = new PDO(mysql:host=$hostname;dbname=animals, $username, $password); $stmt

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.