QSpinBox doesn't send signal valueChanged() anymore



  • Hi,

    I have a QSpinBox drawn within Qt Designer.
    I wrote:

    connect(ui.spinBox_Image_Output, SIGNAL(valueChanged(int)), process, SLOT(requestImage(int)));
    

    It ran perfectly but it doesn't run anymore since 2 hours.
    I put a breakpoint into the slot requestImage. It is never activated as I click onto the up and down arrows of the spin box.
    Could you help please ?

    Many thanks.


  • Qt Champions 2016

    Hi,
    First thing you should do is to use the new syntax, so you get compile-time checking:

    QObject::connect(ui.spinBox_Image_Output, &QSpinBox::valueChanged, process, &MyClass::requestImage);
    

    Besides that you should check the application output pane for any runtime errors you may be getting.



  • I wrote with new version you suggested.
    Doesn't run.


  • Qt Champions 2016

    @mulfycrowh
    What about the second point I made?

    I don't intend to be mean, but "Doesn't run" hasn't any significance at all. Please elaborate: what are you trying, what's expected and what are you getting instead. If you need, attach screenshots, or post contents of additional relevant files.

    Kind regards.



  • Maybe I am disturbing with my issues ...
    I wrote in the first post something very clear.
    It ran and it doesn't run anymore : The program doesn't run requestImage anymore when I click on the arrows


  • Qt Champions 2016

    @mulfycrowh said in QSpinBox doesn't send signal valueChanged() anymore:

    Maybe I am disturbing with my issues ...

    No, since it's the forum's main purpose - to help with issues. But perhaps I'm not understanding the context, and until I do I'm useless at providing help.

    It ran and it doesn't run anymore : The program doesn't run requestImage anymore when I click on the arrows

    How are you running the program, from Qt Creator? What do you get in the Application output pane?



  • I use VS2015 and Qt5.6.1.
    The purpose is to display the image matching with the value in QSpinBox.
    As I click on the arrows the value changes but the slot is not run.
    It ran perfectly before.
    No run time at all


  • Qt Champions 2016

    @mulfycrowh
    hi
    its always nice to know if connection is accepted

    qDebug() << "spinConnect:" << connect(xxx);

    To see it says "True".



  • @mulfycrowh said in QSpinBox doesn't send signal valueChanged() anymore:

    I wrote with new version you suggested.
    Doesn't run.

    @kshegunov solution should not compile at all (valueChanged is an overloaded signal), the fact that you report a "doesn't run" is strange

    try

    QObject::connect(ui.spinBox_Image_Output,static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),process, &std::remove_pointer<decltype(process)>::type::requestImage);
    

    The second thing to check is if you created a function called connect somewhere else in your code



  • Maybe you are going to laugh but in the same time I wrote:

    	connect(ui.spinBox_Image_Output, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), process, &Process::requestImage);
    

    and it works !

    The question now is : why did the previous version run ? and suddenly didn't run anymore ?
    I enjoy understanding the matter



  • the version of connect using SIGNAL() and SLOT() spits a message to cerr (qDebug()) if something goes wrong in the connection. In visual studio put a breakpoint before connect and then step over it and keep an eye in to the debug console (output window with Debug set in the "show output from" combobox) to see what it prints



  • Thanks !


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.