Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTreeWidget::itemDoubleClicked signal not work...
Qt 6.11 is out! See what's new in the release blog

QTreeWidget::itemDoubleClicked signal not work...

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    opengpu2
    wrote on last edited by
    #1

    QTreeWidget::itemDoubleClicked signal not work...
    i write like this in the constructor:
    connect(this, SIGNAL(itemDoubleClicked(QTreeWidget* item, int column), this, SLOT(xxxx(QTreeWidget* item, int column))));
    but the slot not called...
    i do have Q_OBJECT

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      Should be:

      connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(xxxx(QTreeWidgetItem*, int)));
      

      Don't include parameter names in connect statement, just types. Also you mismatched braces and the param type is QTreeWidgetItem* not QTreeWidget*.

      And are you sure the sender should be "this"? Are you calling it from a QTreeWidget inherited class?
      Consider switching to new connect syntax. It's less error prone:

      connect(this, &YourClass::itemDoubleClicked, this, &YourClass::xxxx);
      
      1 Reply Last reply
      0
      • O Offline
        O Offline
        opengpu2
        wrote on last edited by
        #3

        thank you ,solved.
        and which is better?this one?
        connect(this, &YourClass::itemDoubleClicked, this, &YourClass::xxxx);

        and is there any problem if i send from this to this :D

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #4

          There's no better/worse. Both have pros and cons.
          Pro is it's less typing and it's type checked at compile-time. You can also connect lambdas and non-slot functions this way. Con is more typing in case of overloaded methods. You can read about it more here.

          There's no problem connecting this to this. I was just curious if you made an error, but if this derives from QTreeWidget then it's perfectly ok.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved