Results 1 to 20 of 42

Thread: QTreeWidget clicked signal

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #35
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: QTreeWidget clicked signal

    What is the type of item and what is the type of "PLC"?
    And in your code lnx is a local variable in different method so how do you want to reference it in this method?
    I think you need to revise your C++ knowledge...
    Why can't you use QTreeWidgetItem methods like for example text() to get know what item did you clicked?
    You can event set your data with QTreeWidgetItem::setData() with Qt::UserRole while creating item to let you know what item it is.
    Qt Code:
    1. QTreeWidgetItem lnx = new QTreeWidgetItem(ui->treeWidget);
    2. lnx->setData(0, Qt::UserRole, "lnx");
    3.  
    4. // and check it:
    5. if (item->data().toString() == "lnx")
    To copy to clipboard, switch view to plain text mode 

    P.S. And use CODE tags for pasting code! Your code is already a mess in terms of formatting and without CODE tags it is even worse.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

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

    mkkguru (28th January 2010)

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.