Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSpinBox doesn't send signal valueChanged() anymore
Forum Updated to NodeBB v4.3 + New Features

QSpinBox doesn't send signal valueChanged() anymore

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 6 Posters 5.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mulfycrowh
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      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.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mulfycrowh
        wrote on last edited by
        #3

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

        kshegunovK VRoninV 2 Replies Last reply
        0
        • M mulfycrowh

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

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @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.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mulfycrowh
            wrote on last edited by
            #5

            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

            kshegunovK 1 Reply Last reply
            0
            • M mulfycrowh

              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

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by kshegunov
              #6

              @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?

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mulfycrowh
                wrote on last edited by
                #7

                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

                mrjjM 1 Reply Last reply
                0
                • M mulfycrowh

                  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

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

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

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

                  To see it says "True".

                  1 Reply Last reply
                  1
                  • M mulfycrowh

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

                    VRoninV Offline
                    VRoninV Offline
                    VRonin
                    wrote on last edited by VRonin
                    #9

                    @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

                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                    ~Napoleon Bonaparte

                    On a crusade to banish setIndexWidget() from the holy land of Qt

                    1 Reply Last reply
                    1
                    • M Offline
                      M Offline
                      mulfycrowh
                      wrote on last edited by
                      #10

                      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

                      1 Reply Last reply
                      0
                      • VRoninV Offline
                        VRoninV Offline
                        VRonin
                        wrote on last edited by
                        #11

                        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

                        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                        ~Napoleon Bonaparte

                        On a crusade to banish setIndexWidget() from the holy land of Qt

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mulfycrowh
                          wrote on last edited by
                          #12

                          Thanks !

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            AssignOnward
                            wrote on last edited by
                            #13

                            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?

                            kshegunovK 1 Reply Last reply
                            0
                            • A AssignOnward

                              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?

                              kshegunovK Offline
                              kshegunovK Offline
                              kshegunov
                              Moderators
                              wrote on last edited by
                              #14

                              @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.

                              Read and abide by the Qt Code of Conduct

                              Christian EhrlicherC 1 Reply Last reply
                              0
                              • kshegunovK kshegunov

                                @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.

                                Christian EhrlicherC Offline
                                Christian EhrlicherC Offline
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                @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 ...

                                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                Visit the Qt Academy at https://academy.qt.io/catalog

                                kshegunovK 1 Reply Last reply
                                0
                                • Christian EhrlicherC Christian Ehrlicher

                                  @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 ...

                                  kshegunovK Offline
                                  kshegunovK Offline
                                  kshegunov
                                  Moderators
                                  wrote on last edited by
                                  #16

                                  @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.

                                  Read and abide by the Qt Code of Conduct

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved