Results 1 to 3 of 3

Thread: Problem with QTreeWidget after subclassing

  1. #1
    Join Date
    Jul 2006
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Problem with QTreeWidget after subclassing

    I'm having trouble adding QTreeItems to a QTreeWidget after subclassing it. The following code works fine, but no items appear in the treewidget.


    xtreewidget.h
    Qt Code:
    1. #include <QTreeWidget>
    2.  
    3. class xTreeWidget: public QTreeWidget {
    4. Q_OBJECT
    5. public:
    6. xTreeWidget(QWidget *parent);
    7. void redraw();
    8. public slots:
    9. private:
    10. };
    To copy to clipboard, switch view to plain text mode 

    xtreewidget.cpp
    Qt Code:
    1. xTreeWidget::xTreeWidget(QWidget *parent) {
    2. redraw();
    3. }
    4. void xTreeWidget::redraw() {
    5. //Doesn't Work
    6. QTreeWidgetItem *item1 = new QTreeWidgetItem(this);
    7. item1->setText(0,tr("item1"));
    8. //This don't either.
    9. addTopLevelItem(item2);
    10. item2->setText(0,tr("item2"));
    11. }
    To copy to clipboard, switch view to plain text mode 

    Any help would be greatly appreciated.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QTreeWidget after subclassing

    setColumnCount( 1 )?

  3. The following user says thank you to jacek for this useful post:

    steve918 (28th July 2006)

  4. #3
    Join Date
    Jul 2006
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with QTreeWidget after subclassing

    Quote Originally Posted by jacek
    setColumnCount( 1 )?
    That's it!

    Thanks for the quick reply that was killing me for some reason.

Similar Threads

  1. Problem in enabling QtreeWidget items dynamically
    By jyoti kumar in forum Qt Programming
    Replies: 10
    Last Post: 7th June 2006, 18:10
  2. Problem in SubClassing QTableItem.
    By sumsin in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2006, 10:21
  3. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  4. QTreeWidget problem!!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 10th March 2006, 11:47
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.