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. Qt eror: Underfined Reference To
Forum Updated to NodeBB v4.3 + New Features

Qt eror: Underfined Reference To

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 619 Views 1 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
    MinhVN
    wrote on last edited by
    #1

    I am building a QT Creator program that performs two tasks: Task 1: Receive yaw pitch roll signals from esp32 via wifi with tcp socket protocol and display them using label and charts.

    Task 2: On the interface, there will be 4 LineEdits to enter coordinates and tilt angle, then send those 4 LineEdits via wifi to esp32.
    In the source code, it will be divided into 2 header files and 2 cpp files. mainwindow.h and mainwindow.cpp will be responsible for designing the interface and receiving yaw pitch roll then display them; Worker.h and Worker.cpp will be responsible for performing the second task. i am getting "undefined reference to Mainwindow::sendDataBack " error but i have written the declaration in worker.h and definition in worker.cpp.

    i have tried changing the order of included header files but no luck Please help me! i only have 9 days left i also checked every thing to see if i write my function correct but no use.

    C 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      It should rather be:

      • have one controller class that is responsible for communicating with the device
      • have one GUI class that will make use of the controller

      The controller class shall not know anything about the GUI, it's not its role to update the GUI. What it needs to do is emit signals when something new arrives. The GUI shall connect to these signals and do whatever they want with the values received. Give proper API to the controller that the GUI can call to send data to the device.

      Keep things clearly and cleanly separated.

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

      M 1 Reply Last reply
      1
      • SGaistS SGaist moved this topic from Qt in Education on
      • SGaistS SGaist

        Hi and welcome to devnet,

        It should rather be:

        • have one controller class that is responsible for communicating with the device
        • have one GUI class that will make use of the controller

        The controller class shall not know anything about the GUI, it's not its role to update the GUI. What it needs to do is emit signals when something new arrives. The GUI shall connect to these signals and do whatever they want with the values received. Give proper API to the controller that the GUI can call to send data to the device.

        Keep things clearly and cleanly separated.

        M Offline
        M Offline
        MinhVN
        wrote on last edited by
        #3

        @SGaist Can i send you my code so you can help me fix the code? I'm new on this platform.

        SGaistS 1 Reply Last reply
        0
        • M MinhVN

          @SGaist Can i send you my code so you can help me fix the code? I'm new on this platform.

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Unless it's trade secret, you can post it here.

          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
          • M MinhVN

            I am building a QT Creator program that performs two tasks: Task 1: Receive yaw pitch roll signals from esp32 via wifi with tcp socket protocol and display them using label and charts.

            Task 2: On the interface, there will be 4 LineEdits to enter coordinates and tilt angle, then send those 4 LineEdits via wifi to esp32.
            In the source code, it will be divided into 2 header files and 2 cpp files. mainwindow.h and mainwindow.cpp will be responsible for designing the interface and receiving yaw pitch roll then display them; Worker.h and Worker.cpp will be responsible for performing the second task. i am getting "undefined reference to Mainwindow::sendDataBack " error but i have written the declaration in worker.h and definition in worker.cpp.

            i have tried changing the order of included header files but no luck Please help me! i only have 9 days left i also checked every thing to see if i write my function correct but no use.

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

            @MinhVN said in Qt eror: Underfined Reference To:

            i am getting "undefined reference to Mainwindow::sendDataBack " error but i have written the declaration in worker.h and definition in worker.cpp.

            The declaration and definition for Mainwindow::sendDataBack() would normally be expected in the files mainwindow.h/mainwindow.cpp (or something like that). If the Worker class needs to access MainWindow::sendDataBack() then you should only need an #include "mainwindow.h" in the relevant Widget source or header.

            The error message is a linker error. It could be because you have incompatible declarations in the two places.

            SGaistS 1 Reply Last reply
            0
            • C ChrisW67

              @MinhVN said in Qt eror: Underfined Reference To:

              i am getting "undefined reference to Mainwindow::sendDataBack " error but i have written the declaration in worker.h and definition in worker.cpp.

              The declaration and definition for Mainwindow::sendDataBack() would normally be expected in the files mainwindow.h/mainwindow.cpp (or something like that). If the Worker class needs to access MainWindow::sendDataBack() then you should only need an #include "mainwindow.h" in the relevant Widget source or header.

              The error message is a linker error. It could be because you have incompatible declarations in the two places.

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @ChrisW67 The issue was that the slot was declared in both classes and not implemented in MainWindow however, it was a useless slot so its removal fixed the issue at hand.

              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
              • SGaistS SGaist has marked this topic as solved on

              • Login

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