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. Problem in Connecting ctkDoubleSpinBox
Forum Updated to NodeBB v4.3 + New Features

Problem in Connecting ctkDoubleSpinBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
23 Posts 5 Posters 2.7k Views
  • 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 Meera Hadid

    @jsulm

    • do you mean this syntax?
     Counter a, b;
        QObject::connect(&a, &Counter::valueChanged,
                         &b, &Counter::setValue);
    
    • I am getting a syntax error when I use this: this->SliceController->&spinBox
    JonBJ Online
    JonBJ Online
    JonB
    wrote on last edited by JonB
    #11

    @Meera-Hadid said in Problem in Connecting ctkDoubleSpinBox:

    I am getting a syntax error when I use this: this->SliceController->&spinBox

    This is not legal C++. It should be:

    &this->SliceController->spinBox
    

    Whether you want the & depends on whether spinbox is already a pointer or not (I think yours is a pointer, in which case you would not want it?)

    M 1 Reply Last reply
    1
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #12

      @JonB said in Problem in Connecting ctkDoubleSpinBox:

      &this->SliceController->spinBox

      But according to the error message

      cannot convert argument 1 from 'ctkDoubleSpinBox *' to 'const QObject *

      It's already a pointer so the & is wrong.
      I still think the header for this class is not included where the connect is done so the compiler doesn't know that ctkDoubleSpinBox is derived from QObject.

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

      M 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        @JonB said in Problem in Connecting ctkDoubleSpinBox:

        &this->SliceController->spinBox

        But according to the error message

        cannot convert argument 1 from 'ctkDoubleSpinBox *' to 'const QObject *

        It's already a pointer so the & is wrong.
        I still think the header for this class is not included where the connect is done so the compiler doesn't know that ctkDoubleSpinBox is derived from QObject.

        M Offline
        M Offline
        Meera Hadid
        wrote on last edited by
        #13

        @Christian-Ehrlicher

        • I did include #include <ctkDoubleSpinBox.h>
        jsulmJ 1 Reply Last reply
        0
        • M Meera Hadid

          @Christian-Ehrlicher

          • I did include #include <ctkDoubleSpinBox.h>
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #14

          @Meera-Hadid Fix your connect as suggested by @JonB and try again

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • JonBJ JonB

            @Meera-Hadid said in Problem in Connecting ctkDoubleSpinBox:

            I am getting a syntax error when I use this: this->SliceController->&spinBox

            This is not legal C++. It should be:

            &this->SliceController->spinBox
            

            Whether you want the & depends on whether spinbox is already a pointer or not (I think yours is a pointer, in which case you would not want it?)

            M Offline
            M Offline
            Meera Hadid
            wrote on last edited by
            #15

            @JonB

            • Yes when I tried without using & it was raising an error that cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'

            @jsulm

            • The issue is not getting pointer the issue is it cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'
            JonBJ jsulmJ 3 Replies Last reply
            0
            • M Meera Hadid

              @JonB

              • Yes when I tried without using & it was raising an error that cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'

              @jsulm

              • The issue is not getting pointer the issue is it cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'
              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #16

              @Meera-Hadid said in Problem in Connecting ctkDoubleSpinBox:

              @JonB

              Yes when I tried without using & it was raising an error that cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'

              @jsulm

              The issue is not getting pointer the issue is it cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'

              Inserting a & randomly will not help. The message already tells that pointer-ness is not the issue.

              1 Reply Last reply
              0
              • M Meera Hadid

                @JonB

                • Yes when I tried without using & it was raising an error that cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'

                @jsulm

                • The issue is not getting pointer the issue is it cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'
                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #17

                @Meera-Hadid said in Problem in Connecting ctkDoubleSpinBox:

                The issue is not getting pointer the issue is it cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'

                Do you mean you get same error message if you use new connect syntax?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • M Meera Hadid

                  @JonB

                  • Yes when I tried without using & it was raising an error that cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'

                  @jsulm

                  • The issue is not getting pointer the issue is it cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'
                  JonBJ Online
                  JonBJ Online
                  JonB
                  wrote on last edited by JonB
                  #18

                  @Meera-Hadid
                  Please do the following:

                  • First, delete all the files from the build output directory. Do a fresh qmake followed by a build. Does the error still occur?
                  • From the line number in the error message, are you quite sure it is on the connect() statement you have shown, and not some other?
                  • I believe I already advised this before in answer to the same problem from you in another thread: on the line above the connect() put in
                  const QObject *temp = this->SliceController->spinBox;
                  

                  Does that error (show message)?

                  M 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @Meera-Hadid
                    Please do the following:

                    • First, delete all the files from the build output directory. Do a fresh qmake followed by a build. Does the error still occur?
                    • From the line number in the error message, are you quite sure it is on the connect() statement you have shown, and not some other?
                    • I believe I already advised this before in answer to the same problem from you in another thread: on the line above the connect() put in
                    const QObject *temp = this->SliceController->spinBox;
                    

                    Does that error (show message)?

                    M Offline
                    M Offline
                    Meera Hadid
                    wrote on last edited by
                    #19

                    @JonB

                    • const QObject *temp = this->SliceController->spinBox;
                      this works
                    • But the signal SIGNAL(valueChanged(double)) doesn't get activated (QLabel value doesn't change). Is it because temp is returing nullptr?
                    JonBJ 1 Reply Last reply
                    0
                    • M Meera Hadid

                      @JonB

                      • const QObject *temp = this->SliceController->spinBox;
                        this works
                      • But the signal SIGNAL(valueChanged(double)) doesn't get activated (QLabel value doesn't change). Is it because temp is returing nullptr?
                      JonBJ Online
                      JonBJ Online
                      JonB
                      wrote on last edited by
                      #20

                      @Meera-Hadid

                      Is it because temp is returing nullptr?

                      Pardon? Are you saying this->SliceController->spinBox == nullptr at the time you execute the connect() statement?

                      Separately, put a qDebug() statement as the first thing in your void qMRMLSliceWidget::updateLabel().

                      M 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @Meera-Hadid

                        Is it because temp is returing nullptr?

                        Pardon? Are you saying this->SliceController->spinBox == nullptr at the time you execute the connect() statement?

                        Separately, put a qDebug() statement as the first thing in your void qMRMLSliceWidget::updateLabel().

                        M Offline
                        M Offline
                        Meera Hadid
                        wrote on last edited by
                        #21

                        @JonB said in Problem in Connecting ctkDoubleSpinBox:

                        Separately, put a qDebug() statement as the first thing in your void qMRMLSliceWidget::updateLabel().

                        Yes I did but that statement is not getting printed/executed

                        JonBJ 1 Reply Last reply
                        0
                        • M Meera Hadid

                          @JonB said in Problem in Connecting ctkDoubleSpinBox:

                          Separately, put a qDebug() statement as the first thing in your void qMRMLSliceWidget::updateLabel().

                          Yes I did but that statement is not getting printed/executed

                          JonBJ Online
                          JonBJ Online
                          JonB
                          wrote on last edited by
                          #22

                          @Meera-Hadid
                          I have asked you other questions. If you don't want to respond to them that is up to you.

                          M 1 Reply Last reply
                          0
                          • JonBJ JonB

                            @Meera-Hadid
                            I have asked you other questions. If you don't want to respond to them that is up to you.

                            M Offline
                            M Offline
                            Meera Hadid
                            wrote on last edited by
                            #23

                            @JonB

                            • First, delete all the files from the build output directory. Do a fresh qmake followed by a build. Does the error still occur?
                              Since there are a lot of files it takes a lot of time to build hence I did not clear the build.
                            • It's my bad that I assumed this->SliceController->spinBox was returning a nullptr. The problem was with slot I changed it.
                            • const QObject *temp = this->SliceController->spinBox; worked for me

                            Thanks everyone for contributing.

                            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