Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Code worked before, updated Qt and doesn't now :c [SOLVED]



  • To give a bit of explanation:
    The program should link a spinbox and a slider so that as you change the value of one it would alter the value of the other; so at all times these would have the same value. This worked perfectly fine before but after updating it stopped working, here is my code:
    @#include <QApplication>
    #include <QHBoxLayout>
    #include <QSlider>
    #include <QSpinBox>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    QWidget *mainWindow = new QWidget;
    mainWindow->setWindowTitle("How many chicken wings?");
    
    QSpinBox *spinner = new QSpinBox;
    QSlider *slider = new QSlider(Qt::Horizontal);
    spinner->setRange(1,50);
    slider->setRange(1,50);
    QObject::connect(spinner, SIGNAL(valueChange(int)), slider, SLOT(setValue(int)));
    QObject::connect(slider, SIGNAL(valueChange(int)), spinner, SLOT(setValue(int)));
    spinner->setValue(10);
    
    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(slider);
    layout->addWidget(spinner);
    mainWindow->setLayout(layout);
    mainWindow->show();
    
    return a.exec(&#41;;
    

    }
    @

    Any help would be much appreciated.



  • The QSpinBox SIGNAL is not valueChange(int), but valueChanged(int)

    After changing that it works fine with Qt 5.1.



  • Oh wow, that was a simple mistake; thanks!


Log in to reply