Results 1 to 6 of 6

Thread: QTreeWidget and QStackedWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Dec 2009
    Posts
    128
    Platforms
    Unix/X11 Windows
    Thanks
    7
    Thanked 14 Times in 14 Posts

    Default Re: QTreeWidget and QStackedWidget

    this is done in like 3 mins...


    Qt Code:
    1. MyTreeWidget::MyTreeWidget(...)
    2. {
    3. // ...
    4. connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), SLOT(currentItemChanged(QTreeWidgetItem*)))
    5. // ...
    6. }
    7. void MyTreeWidget::populate(...)
    8. {
    9. // ...
    10. QTreeWidgetItem *item = new QTreeWidgetItem("tree_item") ;
    11. item->setUserData(0,Qt::UserRole, PAGE_ID) ; // unique ID HERE
    12. addTopLevelItem(item) ;
    13. // ...
    14. }
    15. void MyTreeWidget::currentItemChanged(QTreeWidgetItem * current)
    16. {
    17. int id = item->data(0,Qt::UserRole).toInt() ;
    18. emit currentIDChanged(id) ;
    19. }
    To copy to clipboard, switch view to plain text mode 



    Qt Code:
    1. MyWindow::MyWindow(...)
    2. {
    3. // MyTreeWidget *p_treeWidget
    4. // QStackedWidget *p_stackedWidget
    5.  
    6. // ...
    7.  
    8. connect(p_treeWidget, SIGNAL(currentIDChanged(int)), p_stackedWidget, SLOT(setCurrentIndex(int))) ;
    9.  
    10. // ...
    11. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to totem for this useful post:

    arturo182 (14th October 2011)

Similar Threads

  1. QStackedLayout / QStackedWidget
    By morraine in forum Newbie
    Replies: 15
    Last Post: 12th July 2013, 10:16
  2. QStackedWidget
    By sattu in forum Qt Programming
    Replies: 6
    Last Post: 28th September 2011, 14:44
  3. QTableWidget along with QStackedWidget
    By smiling in forum Qt Programming
    Replies: 5
    Last Post: 13th March 2010, 13:46
  4. Help with QStackedWidget
    By onírico in forum Newbie
    Replies: 6
    Last Post: 12th November 2009, 17:34
  5. QSplitter and QStackedWidget
    By nikita in forum Qt Programming
    Replies: 4
    Last Post: 15th November 2006, 05:52

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.