prototype of signal QAction::triggered
-
@jsulm said in prototype of signal QAction::triggered:
@jronald There is only https://doc.qt.io/qt-5/qaction.html#triggered
But since checked has a default value you can call triggered() without parameter (parameter will have false as value in this case).But the handler is like
void on_actionOpen_triggered()
(auto generated by the designer) instead ofvoid on_actionOpen_triggered(bool checked = false)
.
Is it legal?@jronald said in prototype of signal QAction::triggered:
Is it legal?
Yes, it is fine if the slot has fewer parameters than signal (but not other way around!).
-
After testing, both proto types of QAction::triggered as below work
void QAction::triggered(bool checked = false)
void QAction::triggered()
But only the former is documented in the doc of
QAction
.
What about the latter one?@jronald There is only https://doc.qt.io/qt-5/qaction.html#triggered
But since checked has a default value you can call triggered() without parameter (parameter will have false as value in this case). -
@jronald There is only https://doc.qt.io/qt-5/qaction.html#triggered
But since checked has a default value you can call triggered() without parameter (parameter will have false as value in this case).@jsulm said in prototype of signal QAction::triggered:
@jronald There is only https://doc.qt.io/qt-5/qaction.html#triggered
But since checked has a default value you can call triggered() without parameter (parameter will have false as value in this case).But the handler is like
void on_actionOpen_triggered()
(auto generated by the designer) instead ofvoid on_actionOpen_triggered(bool checked = false)
.
Is it legal? -
@jsulm said in prototype of signal QAction::triggered:
@jronald There is only https://doc.qt.io/qt-5/qaction.html#triggered
But since checked has a default value you can call triggered() without parameter (parameter will have false as value in this case).But the handler is like
void on_actionOpen_triggered()
(auto generated by the designer) instead ofvoid on_actionOpen_triggered(bool checked = false)
.
Is it legal?@jronald said in prototype of signal QAction::triggered:
Is it legal?
Yes, it is fine if the slot has fewer parameters than signal (but not other way around!).
-
@jsulm said in prototype of signal QAction::triggered:
@jronald There is only https://doc.qt.io/qt-5/qaction.html#triggered
But since checked has a default value you can call triggered() without parameter (parameter will have false as value in this case).But the handler is like
void on_actionOpen_triggered()
(auto generated by the designer) instead ofvoid on_actionOpen_triggered(bool checked = false)
.
Is it legal?@jronald do yourself a favour and do not use the connectSlotByName (
void on_<object name>_<signal name>(<signal parameters>);
) feature, but rather use the Qt5 connect syntax and connect signals to slots by handhttps://doc.qt.io/qt-5/qmetaobject.html#connectSlotsByName
https://wiki.qt.io/New_Signal_Slot_Syntax
https://doc.qt.io/qt-5/signalsandslots.htmlits far less error prone