[Interest] A problem about signals/slots in Qt 5

程梁 devbean at outlook.com
Tue Sep 4 07:14:17 CEST 2012


Hi, there! I try to connect signals and slot in Qt 5 using new syntax. But I have a question: how to connect overloaded signals to special slots?

For example, I have the following code:

    QSpinBox *spinBox = new QSpinBox(&window);
    QSlider *slider = new QSlider(Qt::Horizontal, &window);

    QObject::connect(slider, &QSlider::valueChanged, spinBox, &QSpinBox::setValue);
    QObject::connect(spinBox, &QSpinBox::valueChanged, slider, &QSlider::setValue);

valueChanged() in QSpinBox is an overloaded signal. When I use qmake 2.01a to compile it, the error shows:

    no matching function for call to 'QObject::connect(QSpinBox*&, <unresolved overloaded function type>, QSlider*&, void (QAbstractSlider::*)(int))'

How could I solve this?

In Qt 4 I could specialize the signal using SIGNAL(valueChanged(int)), how could I do in Qt 5?

Cheng Liang
Nanjing, China
http://www.devbean.info 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120904/6e162ad8/attachment.html>


More information about the Interest mailing list