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. Am I calling this method wrong?
Qt 6.11 is out! See what's new in the release blog

Am I calling this method wrong?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 956 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.
  • C Offline
    C Offline
    Comedian
    wrote on last edited by
    #1

    header for class.PNG method.PNG object decl.PNG

    Pl45m4P jsulmJ 2 Replies Last reply
    0
    • C Comedian

      header for class.PNG method.PNG object decl.PNG

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

      @Comedian

      Hi and welcome to the forum,

      it's always better to post code as text using the code format button ( "</>").
      Anyway, it's seems that you are not that familiar with C++ and or OOP programming languages.

      There's a lot stuff going on in you code which is wrong.

      • The call to Ui->cmbPorts.... in your foreach loop does not work like this, because your UI's namespace is named Ui, but not the pointer/instance to your actual compiled Ui class...

      • And even then... you should only access the UI from the same class directly.
        You are in serial.cpp, while the ui, even if spelled correctly, is a private member of MainWindow. It cannot (and should not) be accessed from serial.

      • Your openPort() method in serial.cpp is not even a member function of the serial class... it's just a globally declared function floating around in your serial.cpp file... which is another issue here...

      • therefore the call serial1.openPort() doesn't work... because there is no serial::openPort(), as I explained above

      • also your serial class is missing a constructor... we can't see your serial header, but since you are showing the code file, which contains no class/member functions at all, I doubt it's there.
        The error in your 3rd picture even says "undefined reference to serial::serial"

      Might sound harsh, but I would recommend to learn the C++ basics (Objects, Pointers, Classes, Members, Inheritance and other OOP principles) and then come back before you dive further into Qt now, struggling with small things which are obligatory to work with Qt (and not get frustrated)

      So to answer your question "Am I calling this method wrong?", yes and a couple more mistakes

      @Comedian are you more familiar with Python?!
      Have a look at the Python wrapper for Qt called "PySide"

      Here are some helpful links:

      • https://www.qt.io/qt-for-python
      • https://doc.qt.io/qtforpython-6/
      • https://wiki.qt.io/Qt_for_Python

      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
      • C Comedian

        header for class.PNG method.PNG object decl.PNG

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

        @Comedian One more observation: in on_portQuery_clicked() you create a local variable and then call openPort() on it. This local variable only lives inside on_portQuery_clicked() and will be deleted as soon as on_portQuery_clicked() finishes.

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

        1 Reply Last reply
        1

        • Login

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