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. call to non static member function without an object argument
Forum Updated to NodeBB v4.3 + New Features

call to non static member function without an object argument

Scheduled Pinned Locked Moved Unsolved General and Desktop
23 Posts 10 Posters 13.6k Views 4 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Dis you read the documentation of the method ?

    The first parameter shall be the object that will emit the signal and the third the object that will have the slot activated.

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

    C 1 Reply Last reply
    2
    • SGaistS SGaist

      Dis you read the documentation of the method ?

      The first parameter shall be the object that will emit the signal and the third the object that will have the slot activated.

      C Offline
      C Offline
      Chaki
      wrote on last edited by
      #5

      @SGaist Yes I read it, but I am having trouble to implement it correctly

      Pl45m4P jsulmJ 2 Replies Last reply
      0
      • C Chaki

        @SGaist Yes I read it, but I am having trouble to implement it correctly

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by Pl45m4
        #6

        @Chaki

        The first and third parameter needs to be a pointer to your sender / receiver object.
        What you did can not work and I also think you've put it in the wrong place.


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        0
        • C Chaki

          @SGaist Yes I read it, but I am having trouble to implement it correctly

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #7

          @Chaki said in call to non static member function without an object argument:

          but I am having trouble to implement it correctly

          Then please show what you have now...

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

          C 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Chaki said in call to non static member function without an object argument:

            but I am having trouble to implement it correctly

            Then please show what you have now...

            C Offline
            C Offline
            Chaki
            wrote on last edited by
            #8

            @jsulm currently I am trying:

            mainwindow.cpp:

            void MainWindow::on_btnAdd_clicked()
            {
                addressEntry *name = new addressEntry();
                name->**setName**(ui->lineEdit->text());
            
                
                connect(&name, SIGNAL(addressEntry::entry(QString)), addressReaderWriter::Write(name), SLOT(addressReaderWriter::Write(QString)));
            
              
            }
            

            addressentry.h:

            signals:
                void entry(QString name);
            
            

            addressentry.cpp:

            
            void addressEntry::setName(QString name)
            {
                mName = name;
                emit entry(name);
            
            }
            
            

            addressReaderWriter.h:

            public slots:
                void Write(QString);
            

            addressReaderWriter.cpp

            void addressReaderWriter::Write(QString name){
              name.getName();
            
            
                 
            }
            
            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #9

              Your signal/slot signatures in the connect() are wrong. Please read https://doc.qt.io/qt-5/signalsandslots.html before using something.

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

              C 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                Your signal/slot signatures in the connect() are wrong. Please read https://doc.qt.io/qt-5/signalsandslots.html before using something.

                C Offline
                C Offline
                Chaki
                wrote on last edited by
                #10

                @Christian-Ehrlicher I know that the connect is wrong and I have read the Docu, but I am having trouble using it correctly

                jsulmJ 1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  There is so much wrong in your code I don't even know where to start. I would suggest you to start with one of the Qt examples and learn c++ - sorry.

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

                  1 Reply Last reply
                  0
                  • C Chaki

                    @Christian-Ehrlicher I know that the connect is wrong and I have read the Docu, but I am having trouble using it correctly

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by jsulm
                    #12

                    @Chaki said in call to non static member function without an object argument:

                    I have read the Docu

                    If you did then why are you still doing it wrongly? Your code does not even make sence to be honest.

                    connect(name, &addressEntry::entry, addressReaderWriterInstancePtr, &addressReaderWriter::Write);
                    

                    addressReaderWriterInstancePtr would be a pointer to an instance of addressReaderWriter which you want to react on the signal.

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

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

                      @MalitheBIG said in call to non static member function without an object argument:

                      Thats not how you treat new useres who try to get into QT.

                      Before you learn Qt you have to learn c++, thats the reality - sorry.

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

                      1 Reply Last reply
                      3
                      • M Offline
                        M Offline
                        Mr_Kohli
                        wrote on last edited by
                        #14

                        @MalitheBIG Da stimme ich Ihnen zu

                        1 Reply Last reply
                        0
                        • jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #15

                          @MalitheBIG said in call to non static member function without an object argument:

                          NUR WEIL DU EHRLICH

                          Bitte nicht persöhnlich werden...

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

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            Mr_Kohli
                            wrote on last edited by
                            #16

                            @MalitheBIG That's true, maybe try and help him instead of just calling him stupid

                            Christian EhrlicherC 1 Reply Last reply
                            1
                            • M Mr_Kohli

                              @MalitheBIG That's true, maybe try and help him instead of just calling him stupid

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

                              @Mr_Kohli said in call to non static member function without an object argument:

                              instead of just calling him stupid

                              I never did - I told him/her to learn basic c++ before starting with Qt.

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

                              1 Reply Last reply
                              0
                              • J.HilkJ Offline
                                J.HilkJ Offline
                                J.Hilk
                                Moderators
                                wrote on last edited by
                                #18

                                @MalitheBIG what are you talking about, knowing/learning c++ is not personal stuff its essential to use Qt


                                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                Q: What's that?
                                A: It's blue light.
                                Q: What does it do?
                                A: It turns blue.

                                1 Reply Last reply
                                2
                                • jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #19

                                  @MalitheBIG Qt is a C++ framework. How do you want to use Qt without knowing C++?

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

                                  1 Reply Last reply
                                  3
                                  • JonBJ Offline
                                    JonBJ Offline
                                    JonB
                                    wrote on last edited by JonB
                                    #20

                                    @MalitheBIG , @Chaki
                                    In order to use Qt you do need to know C++. This forum is for helping people with Qt questions. We do try, but we are not a C++ tutorial forum. That's just how it is.

                                    There's nothing wrong with learning to program and not yet knowing C++ well enough. Nobody blames you for that. It's just that here is not the best place to ask about C++ questions, there are better, more suitable C++ learning forums out there.

                                    Having said that. The Qt connect() statement requires 4 arguments, 2 pairs of 2, as follows:

                                    connect(signallingObject, signallingMethod,
                                            slotObject, slotMethod);
                                    
                                    • signallingObject is some object on which something happens --- like a click.
                                    • signallingMethod is a method (belonging to the signallingObject class, declared as a signals method in the .h file).
                                    • slotObject is some object which wants to know when the event happens --- like, show a message when signallingObject gets clicked.
                                    • slotMethod is a method (belonging to the slotObject class, declared as a slots method in the .h file). slotMethod should accept the parameters which signallingMethod sends.

                                    So a simple example example looks like

                                    // In, say, your `MainWindow` class
                                    connect(ui->someButton, &QPushButton::clicked,
                                            this, &MainWindow::onButtonClicked);
                                    
                                    /*slot*/ MainWindow::onButtonClicked()
                                    {
                                        qDebug() << "Button was clicked";
                                    }
                                    

                                    The important think is that the connect() will usually look like:

                                    connect(signallingObject, &SignallingObjectClass::method,
                                            slotObject, &SlotObjectClass::method);
                                    

                                    You would benefit hugely from taking some time to study some of the tutorial signals & slots examples out there on the web. They are better than asking people here to come up with examples. If you Google for qt5 signal slot tutorial you get several suggestions, not only in the Qt docs, which is where I would start from:
                                    https://doc.qt.io/qt-5/signalsandslots.html
                                    https://www.bogotobogo.com/Qt/Qt5_SignalsSlotsGui.php
                                    https://prognotes.net/2019/12/qt-5-signals-and-slots-tutorial/
                                    https://www.vikingsoftware.com/getting-the-most-of-signal-slot-connections/
                                    https://wiki.qt.io/New_Signal_Slot_Syntax

                                    P.S.
                                    I will strongly recommend one thing. In @Chaki's code, and in a lot of older examples on the web, the old style SIGNAL() & SLOT() macros are used for the methods. Do not do this. It might look simpler than the new style &Class::method, but it allows you to write nonsense, which gets through the compiler but doesn't work at runtime. Using the new style will only allow you to write something sensible at compile time, and if it rejects what you try it means it was not correct. The new style is covered in the https://wiki.qt.io/New_Signal_Slot_Syntax link I gave above.

                                    1 Reply Last reply
                                    8
                                    • KroMignonK Offline
                                      KroMignonK Offline
                                      KroMignon
                                      wrote on last edited by
                                      #21

                                      @MalitheBIG said in call to non static member function without an object argument:

                                      @jsulm Naja wenn man sowas schreibt finde ich das nicht ganz so nett! Man könnte ja etwas Nettigkeit and den Tag legen!

                                      Why are you fell hurt when he asked you to learn first C++ basics before trying to develop with Qt, which is a C++ framework!
                                      Would you also be hurt if someone tells you to first learn Python before trying to use Django?

                                      When you try to build a house, do you start with the roof before the foundations?

                                      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                                      1 Reply Last reply
                                      3
                                      • jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #22

                                        I suggest to stop the off-topic discussion here. If somebody wants to continue please create a new thread and link to this one.

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

                                        1 Reply Last reply
                                        2
                                        • Pl45m4P Offline
                                          Pl45m4P Offline
                                          Pl45m4
                                          wrote on last edited by Pl45m4
                                          #23

                                          @MalitheBIG @Chaki

                                          lol, you guys feel offended, when getting told to look at the docs for about 5 mins again...
                                          I think we had the same discussion with some other users before.
                                          If you looked at the docs, and still don't know what to do, you should really consider to improve your C++ knowledge.... you don't need to be an expert in C++ to use this basic Qt stuff.

                                          This is also a volunteer's forum. Most people here can help you with your Qt and / or C++ issue, but nobody will teach you basic C++.

                                          Btw: If you would have posted the same question elsewhere (SO, cough), you would get roasted very badly ;-)


                                          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                                          ~E. W. Dijkstra

                                          1 Reply Last reply
                                          2

                                          • Login

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