Solved QSpinBox doesn't send signal valueChanged() anymore
-
I wrote with new version you suggested.
Doesn't run. -
@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 -
@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 -
@mulfycrowh
hi
its always nice to know if connection is acceptedqDebug() << "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()
andSLOT()
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 !
-
Having a closely related issue, since this is the first Google search result trying here to collect the info somewhere useful.
Application running from Qt Creator 5.0.2, default "Desktop" Qt 5.12.8 in path under Ubuntu 20.04.3
Using the "old" syntax:
qDebug() << "spinConnect:" << connect( ui->spinBox, SIGNAL(valueChanged(int)), myOb, SLOT(spinSlot(int)) );The Application Output window shows spinConnect: true
spinSlot() is called with the new values as expected, when using only the up/down controls on the QSpinBox (in a form created using QtCreator).
My problem comes when I click in spinBox and edit the value, sometimes spinSlot() will update correctly, but sometimes it will stop updating and even the up/down controls no longer cause spinSlot() to update - the ui of spinBox does update, but the connected spinSlot() no longer is receiving new values.
I am unable to get the new syntax to compile,
qDebug() << "spinConnect:" << QObject::connect( ui->spinBox, &QSpinBox::valueChanged, myOb, &MyObject::spinSlot );
inside MyObject, spinSlot is declared with inline code in the .h file, if that matters?
public slots:
void spinSlot( int v ) { setValue(v); }I feel like this is an issue within the QSpinBox, more than my connection to it, since the connection is always succeeding but seems to break when the user interacts with the spinBox in certain ways. Other than the qDebug above, no other messages are being shown in the Application Output window.
Is there anything that can trigger the QSpinBox to stop emitting valueChanged(int) signals?
-
@AssignOnward said in QSpinBox doesn't send signal valueChanged() anymore:
I am unable to get the new syntax to compile,
Share the error message you're getting, so we can work this out.
-
@kshegunov said in QSpinBox doesn't send signal valueChanged() anymore:
Share the error message you're getting, so we can work this out.
No need - a simple look in the documentation reveals it. But who needs a documentation ...
-
@Christian-Ehrlicher said in QSpinBox doesn't send signal valueChanged() anymore:
No need - a simple look in the documentation reveals it. But who needs a documentation ...
I assume it's the overload resolution, I wanted it confirmed.