confused by clicked() and clicked(bool) in qt 4 signal and slot
I am using qt 4.8.6 and visual studio 2008 to develop a project and confused by clicked() and clicked(bool). While building a connection for an object which will emit a signal:
connect(sender, SIGNAL(clicked(bool)), receiver, SLOT(myslot()));
will trigger myslot(); and
connect(sender, SIGNAL(clicked()), receiver, SLOT(myslot()));
will not trigger it. However, I find other many examples about connect which all use clicked() not clicked(bool). Why cannot I use clicked()? I look through Qt Assistant about:
void QAbstractButton::clicked ( bool checked = false ) [signal]
This signal is emitted when the button is activated (ie pressed down then released while the mouse cursor is inside the button), when the shortcut key is typed, or when click() or animateClick() is called. Notably, this signal is not emitted if you call setDown(), setChecked() or toggle().
If the button is checkable, checked is true if the button is checked, or false if the button is unchecked.
I cannot find its reason. At the same time, what are the differences of the "checked" and "unchecked"?
By the way, I build a connect by pressing the left mouse button and drag the cursor. Another way is to rightclick the object, then the context menu will applear "go to slot", but my Qt Designer(4.8.6) will not. How to deal with it?
3 quesions hope to get help. Many thanks in advance.
I'm not sure I really understand the question(s), but the reason you can't connect to a clicked()
signal is because there is no such thing... the function profile is clearly clicked(bool)
(see docs).
Qt will only show a runtime error when it can't connect signal/slot (qWarning to stderr), it is not obvious at compile-time. Try examining the program output for warnings.
Edit: removed misleading information.
链接地址: http://www.djcxy.com/p/39318.html上一篇: 用或不用导出定义一个变量