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. Error: no matching function for call to 'QObject::connect
QtWS25 Last Chance

Error: no matching function for call to 'QObject::connect

Scheduled Pinned Locked Moved Unsolved General and Desktop
30 Posts 6 Posters 29.1k 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.
  • P Online
    P Online
    Paul Colby
    wrote on 3 Jan 2018, 00:46 last edited by Paul Colby 1 Mar 2018, 00:47
    #20

    The problem is with the winContent lifetime.

    void MainWindow::buildPage()
    {
        MainWindowContent winContent;
    
        ui->centralWidget->setLayout(winContent.getPageWidgetsLayout());
        // at this point, winContent is destroyed, and automatically disconnected.
    }
    

    You probably want to do something more like:

    void MainWindow::buildPage()
    {
        MainWindowContent * winContent = new MainWindowContent(this);
    
        ui->centralWidget->setLayout(winContent->getPageWidgetsLayout());
    }
    

    Or move the slot to the MainWindow class.

    Cheers.

    1 Reply Last reply
    4
    • W Offline
      W Offline
      WhatIf
      wrote on 3 Jan 2018, 22:20 last edited by
      #21

      Thank you very much for all the help!

      The last problem I have is how to pass the label and lineedit to the slot. I don't want to make them global variables. if I create a custom signal with the label and lineedit to match the slot, I'm confused about where to emit the signal.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 3 Jan 2018, 23:12 last edited by
        #22

        Before that, why do you need the MainWindowContent. It looks like a convoluted mean to create the central widget content.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • W Offline
          W Offline
          WhatIf
          wrote on 4 Jan 2018, 01:26 last edited by
          #23

          I want to keep the logic of how the program progresses from page to page in MainWindow. But I want other classes to generate the pages to be displayed. Basically I want to be able to manage the program without having a single .cpp file that is a thousand lines or so.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 4 Jan 2018, 07:06 last edited by
            #24

            Then why not make them full QWidget derivative ?

            That's what is usually done, cut your application in logical pieces and then build as many QWidget based classes as needed to keep the code clean, simple and tidy.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • W Offline
              W Offline
              WhatIf
              wrote on 4 Jan 2018, 10:12 last edited by
              #25

              Can you give an example please? Or direct me to any tutorial on the topic?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 4 Jan 2018, 20:15 last edited by
                #26

                The scribble example is a simple example to start with.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • W Offline
                  W Offline
                  WhatIf
                  wrote on 9 Jan 2018, 17:01 last edited by
                  #27

                  I went over the example but I still have some difficulty converting it to my use. I created a MainWindowContent that is a subclass of QWidget and created a

                  QGridLayout* MainWindowContent::getPageWidgetsLayout()
                  

                  the exact same function I provided in the code above.

                  I don't think that this is the intended goal of this example because in MainWindow an instance of the QWidget subclass (ScribbleArea) is passed to setCentralWidget not a call to a function using the instance. Am I supposed to move all the code from getPageWidgetsLayout() to the constructor and declare the label, lineedit, and pushbutton as private variables.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 9 Jan 2018, 21:27 last edited by
                    #28

                    No the example shows what I suggested: create a separated widget that encapsulates the functionality of interest and use that one in the MainWindow.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • W Offline
                      W Offline
                      WhatIf
                      wrote on 10 Jan 2018, 19:40 last edited by
                      #29

                      Finally, I got it to work but I still have the same problem that I started with. How do I pass the line edit and label to the slot?

                      I searched online and all the examples have a condition other than the button being clicked that emit the signal . Any hints please?

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        VRonin
                        wrote on 10 Jan 2018, 19:49 last edited by
                        #30

                        https://forum.qt.io/topic/86414/error-no-matching-function-for-call-to-qobject-connect/5

                        "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

                        29/30

                        10 Jan 2018, 19:40

                        • Login

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