Results 1 to 3 of 3

Thread: QTreeWidget::itemDoubleClicked

  1. #1
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTreeWidget::itemDoubleClicked

    Hi,
    I have a programe in QT. In that program I create a tree using treewidget. I want to read data when i double click on an element of that tree. We can use the event " void QTreeWidget::itemDoubleClicked ( QTreeWidgetItem * item, int column ) " , But how can i read the data from the tree?
    Please help me

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeWidget::itemDoubleClicked

    It's not an event - it's a signal. Connect a custom slot to it and use "item" to access the data using text(), icon() or data() (depending on what piece of data you want).

  3. #3
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QTreeWidget::itemDoubleClicked

    QTreeWidgetItem *item = currentItem(); will give you current selected item.
    you can read item text by
    QString itemName = item->text(0);
    you can read data like:
    QString itemID = item->data(0,Qt::AccessibleDescriptionRole).toString( );

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.