QTreeWidget::itemDoubleClicked signal not work...
-
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 -
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);
-
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
-
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.