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. Program compiles and runs , but won't debug - missing includes
Forum Updated to NodeBB v4.3 + New Features

Program compiles and runs , but won't debug - missing includes

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 628 Views 3 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    Program compiles and runs , but won't debug - missing includes

    I am posting this in a new thread, it is not same as the other "includes" problem .

    Here is anther "problem " with "#include " I could use some serious help with solving it. .

    I am still not sure how to build my own application so I am STILL using cloned example. It works just fine and I like to sort of reverse engineer / debug it to learn more.

    The example has simple "button" to perform bluetooth scan AND IT WORKS.

    What I want is to see the source code processing this button push.

    So I do in "device.ui"

    right clicks on "scan" button and

    Go to slot..

    And this is the result

    0311ca7b-f468-4e8a-a714-e1ad4fe1bd89-image.png

    So the stupid question is
    if the application compile and runs it must have all necessary "#includes" etc.

    so why am I getting this " cannot find it " error ?

    what am I missing here ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Anonymous_Banned275
      wrote on last edited by
      #2

      I believe I have identified "the problem".
      The example application was build as Qt "text" application , what I am trying to do is debug it as "GUI". Hence the application does not know anything about "slots" and Qt Designer.

      So the question is

      how to ADD GUI QT Designer (includes ) to my app?
      (I will start with what is "Ui " object )

      I did try to the other way - start my app as Qt Designer , however, I do care more about NOT reinventing the real and working code , the GUI is pretty much just additional "bells and whistles" for me.

      I think what got me confused was "device,ui" - hod did it get generated originally without using Qt Designer.
      So if my theory is correct - is there a example using both Qt and Qt Designer SAME time ?

      That would help.

      Pl45m4P 1 Reply Last reply
      0
      • A Anonymous_Banned275

        I believe I have identified "the problem".
        The example application was build as Qt "text" application , what I am trying to do is debug it as "GUI". Hence the application does not know anything about "slots" and Qt Designer.

        So the question is

        how to ADD GUI QT Designer (includes ) to my app?
        (I will start with what is "Ui " object )

        I did try to the other way - start my app as Qt Designer , however, I do care more about NOT reinventing the real and working code , the GUI is pretty much just additional "bells and whistles" for me.

        I think what got me confused was "device,ui" - hod did it get generated originally without using Qt Designer.
        So if my theory is correct - is there a example using both Qt and Qt Designer SAME time ?

        That would help.

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

        @AnneRanch said in Program compiles and runs , but won't debug - missing includes:

        I think what got me confused was "device,ui" - hod did it get generated originally without using Qt Designer.
        So if my theory is correct - is there a example using both Qt and Qt Designer SAME time ?

        QtDesigner does nothing itself... It's a helper program which translates a kind of WYSIWYG editor into XML style code. If you drag a Pushbutton on your form, the Designer saves all information (name, position, geometry...) about that button in your UI file...

        Every project with UI files is a GUI project, where the programmer could have used the QtDesigner to create the GUI template or not.
        A project without any GUI would be a console program.

        And.. yes, the example that you are currently using, IS a Qt GUI project. I would say 99% of all Qt examples are.

        @Chris-Kawa made a very detailed explanation here.
        Maybe some things become clearer if you read it again.
        https://forum.qt.io/topic/107777/academic-question-how-to-manage-qt-many-colors/14

        @AnneRanch said in Program compiles and runs , but won't debug - missing includes:

        how to ADD GUI QT Designer (includes ) to my app?

        UI definitions can be added to the project by adding them to your pro file (be careful with the paths). It happens automatically, when you add a new one by using the context menu "wizard".
        (Right click on your project folder, then "Add...")

        FORMS = \
            device.ui \
            service.ui
        

        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
        3
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #4

          @AnneRanch said in Program compiles and runs , but won't debug - missing includes:

          What I want is to see the source code processing this button push.
          So I do in "device.ui"
          right clicks on "scan" button and
          Go to slot..

          "Go to slot" is a wizard for generating automatic name based connections. Don't use it for browsing as it can generate new code you didn't intended to. Examples don't usually use that feature. There could also be multiple connections to different slots so it most likely wouldn't take you where you want to go anyway.

          The easiest way to find out how a particular widget from designer form is used is to select the widget, go to its properties panel, check its name (scan in this case) and do a search for its use from the generated ui pointer (ui->scan in this case). You can usually tighten that to just connections with connect(ui->scan search. In this case it will lead you to a connection in the constructor of device.cpp and from there to a slot DeviceDiscoveryDialog::startScan().

          So the stupid question is
          if the application compile and runs it must have all necessary "#includes" etc.
          so why am I getting this " cannot find it " error ?

          This is because the example is not using the auto connection feature I mentioned. Also there are couple of ways you can include the generated content and this example is using a method (using the underscored Ui_ type) which is not recognized by the wizard (which expects namespaced class name).

          IMO this auto connection thing is a misfeature and I suggest you avoid it.

          A 1 Reply Last reply
          4
          • Chris KawaC Chris Kawa

            @AnneRanch said in Program compiles and runs , but won't debug - missing includes:

            What I want is to see the source code processing this button push.
            So I do in "device.ui"
            right clicks on "scan" button and
            Go to slot..

            "Go to slot" is a wizard for generating automatic name based connections. Don't use it for browsing as it can generate new code you didn't intended to. Examples don't usually use that feature. There could also be multiple connections to different slots so it most likely wouldn't take you where you want to go anyway.

            The easiest way to find out how a particular widget from designer form is used is to select the widget, go to its properties panel, check its name (scan in this case) and do a search for its use from the generated ui pointer (ui->scan in this case). You can usually tighten that to just connections with connect(ui->scan search. In this case it will lead you to a connection in the constructor of device.cpp and from there to a slot DeviceDiscoveryDialog::startScan().

            So the stupid question is
            if the application compile and runs it must have all necessary "#includes" etc.
            so why am I getting this " cannot find it " error ?

            This is because the example is not using the auto connection feature I mentioned. Also there are couple of ways you can include the generated content and this example is using a method (using the underscored Ui_ type) which is not recognized by the wizard (which expects namespaced class name).

            IMO this auto connection thing is a misfeature and I suggest you avoid it.

            A Offline
            A Offline
            Anonymous_Banned275
            wrote on last edited by
            #5

            @Chris-Kawa @Chris-Kawa made a very detailed explanation here.
            Maybe some things become clearer if you read it again.
            https://forum.qt.io/topic/107777/academic-question-how-to-manage-qt-many-colors/14

            I have to profusely apologize of being ignorant about this post. Real senior moment...

            I did byte off more than I can chew and trying to "improve " bluetooth example by starting with my own "ui_mainwindow.hi" as a wrapper for other forms.
            However, since "ui_...h" is generated I am not sure if I can "link / cascade " individual "ui .." headers.

            I did try using "tab" widget and it sort of works best for my project.

            At this time I really need to pay attention to these headers, and make sure I do not mix C code "events" and "slots".

            Thanks

            Pl45m4P 1 Reply Last reply
            0
            • A Anonymous_Banned275

              @Chris-Kawa @Chris-Kawa made a very detailed explanation here.
              Maybe some things become clearer if you read it again.
              https://forum.qt.io/topic/107777/academic-question-how-to-manage-qt-many-colors/14

              I have to profusely apologize of being ignorant about this post. Real senior moment...

              I did byte off more than I can chew and trying to "improve " bluetooth example by starting with my own "ui_mainwindow.hi" as a wrapper for other forms.
              However, since "ui_...h" is generated I am not sure if I can "link / cascade " individual "ui .." headers.

              I did try using "tab" widget and it sort of works best for my project.

              At this time I really need to pay attention to these headers, and make sure I do not mix C code "events" and "slots".

              Thanks

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

              @AnneRanch said in Program compiles and runs , but won't debug - missing includes:

              with my own "ui_mainwindow.hi" as a wrapper for other forms.
              However, since "ui_...h" is generated I am not sure if I can "link / cascade " individual "ui .." headers.

              You dont need to do that and you shouldn't.
              ui_xxxxxx.h files are generated by uic from your ui definition file (xxxx.ui)

              @Chris-Kawa said in Academic question - how to manage Qt "many colors"?:

              qmake generates make rules that run uic on the mainwindow.ui file and generate ui_mainwindow.h file
              Files mainwindow.h, mainwindow.cpp, moc_mainwindow.cpp and ui_mainwindow.h, all standard c++, are sent to compiler.
              mainwindow.ui (the xml) is not compiled or used at runtime. Its only purpose is generating ui_mainwindow.h and it's a one-way thing.

              So you shouldnt try to include your own ui_xxx.h headers nor edit the existing ones (uic will override changes anyway)

              @AnneRanch said in Program compiles and runs , but won't debug - missing includes:

              starting with my own "ui_mainwindow.hi" as a wrapper for other forms

              Start with mainWindow.ui, the corresponding header (ui_mainwindow.h) which contains your GUI design definitions in c++ compilable language, will be generated by uic

              @AnneRanch said in Program compiles and runs , but won't debug - missing includes:

              I do not mix C code "events" and "slots"

              Slots are basically just functions made for Qt's Signal & Slot mechanism (https://doc.qt.io/qt-5/signalsandslots.html)
              Since Qt5 you can even connect your signals to normal functions by using the new synax (https://wiki.qt.io/New_Signal_Slot_Syntax)

              Events:

              • https://doc.qt.io/qt-5/eventsandfilters.html
              • https://doc.qt.io/qt-5/qevent.html#details

              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
              1
              • A Offline
                A Offline
                Anonymous_Banned275
                wrote on last edited by Anonymous_Banned275
                #7

                I am pressed for time so I did not read last post , I'll later.

                Here is what I did not realize - the btscanner example I have been trying to copy is a part of "qtconnectivity examples bluetooth branch " . As such it contains many "includes" external to btscanner.

                16a3d0ca-c6c5-49c9-92bd-ada285d7ab23-image.png

                To continue with my philosophy not to reinvent the wheel and reuse perfectly working program I indeed need to start with "examples" and add or modify forms in existing btscanner - "sub - example ".
                Not starting from scratch, the "includes" get to intertwined and "Adding exiting file ..." does not completely add everything.

                Back to some questions. if I may .

                I did try to find the "slot" for "scan" but I do not get the mechanics.
                Partially because I am still missing official names of QtDesigner panes.
                I can select the "scan" button in "tree widgets" to get its properties but cannot figure out how to find the "scan -> pointer ".

                I realize that there already is "scan slot" but the only way to TRY to get there is to right click on "scan" and try to "Go to slot ..."

                then I get this error

                d12f01bb-6715-4519-9055-f89189d54acd-image.png

                and I am stuck -

                why is Ui::DeviceDiscovery "missing" ?

                Pl45m4P 1 Reply Last reply
                0
                • A Anonymous_Banned275

                  I am pressed for time so I did not read last post , I'll later.

                  Here is what I did not realize - the btscanner example I have been trying to copy is a part of "qtconnectivity examples bluetooth branch " . As such it contains many "includes" external to btscanner.

                  16a3d0ca-c6c5-49c9-92bd-ada285d7ab23-image.png

                  To continue with my philosophy not to reinvent the wheel and reuse perfectly working program I indeed need to start with "examples" and add or modify forms in existing btscanner - "sub - example ".
                  Not starting from scratch, the "includes" get to intertwined and "Adding exiting file ..." does not completely add everything.

                  Back to some questions. if I may .

                  I did try to find the "slot" for "scan" but I do not get the mechanics.
                  Partially because I am still missing official names of QtDesigner panes.
                  I can select the "scan" button in "tree widgets" to get its properties but cannot figure out how to find the "scan -> pointer ".

                  I realize that there already is "scan slot" but the only way to TRY to get there is to right click on "scan" and try to "Go to slot ..."

                  then I get this error

                  d12f01bb-6715-4519-9055-f89189d54acd-image.png

                  and I am stuck -

                  why is Ui::DeviceDiscovery "missing" ?

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

                  @AnneRanch

                  @Chris-Kawa answered to exact that question two posts earlier :)
                  https://forum.qt.io/topic/117850/program-compiles-and-runs-but-won-t-debug-missing-includes/4

                  You should really start reading the replies first before asking the same or similar questions again and again.

                  I know, there is much to learn / to understand when you start with Qt or GUI programming in general.


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

                  ~E. W. Dijkstra

                  A 1 Reply Last reply
                  2
                  • Pl45m4P Pl45m4

                    @AnneRanch

                    @Chris-Kawa answered to exact that question two posts earlier :)
                    https://forum.qt.io/topic/117850/program-compiles-and-runs-but-won-t-debug-missing-includes/4

                    You should really start reading the replies first before asking the same or similar questions again and again.

                    I know, there is much to learn / to understand when you start with Qt or GUI programming in general.

                    A Offline
                    A Offline
                    Anonymous_Banned275
                    wrote on last edited by
                    #9

                    @Pl45m4 Well it may look as I am asking same thing over and over .
                    But I feel like Archimedes "Give me the place to stand, and I shall move the earth."
                    There is ONLY one thing solid in Qt and its derivatives and even that is iffy. I may have asked this when I started years or so ago - give me some feel of concept.
                    Qt is a mix of C and C++ and as such there is one solid point - "main" function.
                    Than one can go UP the chain - to find "#include x.h" for "main".
                    Than the fun starts with main instance of QApplication app(argc, argv); class and other classes , where the "meat and potatoes" of the project reside . Eventually "app" gets executed.

                    Now "the other classes" can be Qt , QtDesigenr etc.
                    With QtDesigenr we get x.h , x,ui , ui-x.h etc with well defined relations but "do your best guess" how it all fits together.

                    The we have x.pro and that is mystery how it fits.
                    Not mentioning "make" "qmake" compiler...

                    Enough rant.
                    If the examples projects were not created using "ui automation wizard" to build "slots" the Qt form designer is pretty useless to find them. .
                    (Yes I did read that part -see missing "Ui::xxx ")

                    I did find the btscanner uses "connect" function and hopefully I can decipher how that works .

                    It looks as I can modify current class/ classes to include inheritance of "UI" class. Or create new class and inherit form "UI -less" original class and add "UI " . Just another layer of code.

                    Question
                    Does QtCreator has means to display "inheritance tree " stricture ?
                    Probably.

                    Pl45m4P Chris KawaC 2 Replies Last reply
                    0
                    • A Anonymous_Banned275

                      @Pl45m4 Well it may look as I am asking same thing over and over .
                      But I feel like Archimedes "Give me the place to stand, and I shall move the earth."
                      There is ONLY one thing solid in Qt and its derivatives and even that is iffy. I may have asked this when I started years or so ago - give me some feel of concept.
                      Qt is a mix of C and C++ and as such there is one solid point - "main" function.
                      Than one can go UP the chain - to find "#include x.h" for "main".
                      Than the fun starts with main instance of QApplication app(argc, argv); class and other classes , where the "meat and potatoes" of the project reside . Eventually "app" gets executed.

                      Now "the other classes" can be Qt , QtDesigenr etc.
                      With QtDesigenr we get x.h , x,ui , ui-x.h etc with well defined relations but "do your best guess" how it all fits together.

                      The we have x.pro and that is mystery how it fits.
                      Not mentioning "make" "qmake" compiler...

                      Enough rant.
                      If the examples projects were not created using "ui automation wizard" to build "slots" the Qt form designer is pretty useless to find them. .
                      (Yes I did read that part -see missing "Ui::xxx ")

                      I did find the btscanner uses "connect" function and hopefully I can decipher how that works .

                      It looks as I can modify current class/ classes to include inheritance of "UI" class. Or create new class and inherit form "UI -less" original class and add "UI " . Just another layer of code.

                      Question
                      Does QtCreator has means to display "inheritance tree " stricture ?
                      Probably.

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

                      @AnneRanch said in Program compiles and runs , but won't debug - missing includes:

                      Than the fun starts with main instance of QApplication app(argc, argv); class and other classes , where the "meat and potatoes" of the project reside . Eventually "app" gets executed.
                      Now "the other classes" can be Qt , QtDesigenr etc.
                      With QtDesigenr we get x.h , x,ui , ui-x.h etc with well defined relations but "do your best guess" how it all fits together.
                      The we have x.pro and that is mystery how it fits.

                      It's neither random whether a Qt project runs or not, nor mysterious :)

                      @AnneRanch said in Program compiles and runs , but won't debug - missing includes:

                      Not mentioning "make" "qmake" compiler

                      qMake / make is not a compiler.

                      @AnneRanch said in Program compiles and runs , but won't debug - missing includes:

                      I did find the btscanner uses "connect" function and hopefully I can decipher how that works .

                      The connect statement sets up what will happen, when the signal (button click, custom signal or whatever) is emitted.
                      Connections are a good place to start to see what's going on in a GUI project.
                      https://doc.qt.io/qt-5/signalsandslots.html

                      @AnneRanch said in Program compiles and runs , but won't debug - missing includes:

                      It looks as I can modify current class/ classes to include inheritance of "UI" class. Or create new class and inherit form "UI -less" original class and add "UI " . Just another layer of code.

                      With ui->..... you get access to your widgets, you've (or somebody else) created in QtDesigner before. The corresponding file is the ui_xxxxxx.h header which is basically a c++ code "copy" or translation from your xxxx.ui file.

                      @AnneRanch said in Program compiles and runs , but won't debug - missing includes:

                      Does QtCreator has means to display "inheritance tree " stricture ?

                      What do you mean by "display inheritance tree"?
                      You can see the inherited class in Qt docs or you can follow a class by debugging the Qt headers
                      Mark a Q.... class with your mouse and press F1 to open help / docs in QtCreator or click on the class name while holding Shift or Ctrl (I mix them up sometimes, but it's one of those two commands).


                      Might be helpful:

                      • https://doc.qt.io/qtcreator/creator-writing-program.html
                      • https://doc.qt.io/qt-5/designer-using-a-ui-file.html

                      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
                      • A Anonymous_Banned275

                        @Pl45m4 Well it may look as I am asking same thing over and over .
                        But I feel like Archimedes "Give me the place to stand, and I shall move the earth."
                        There is ONLY one thing solid in Qt and its derivatives and even that is iffy. I may have asked this when I started years or so ago - give me some feel of concept.
                        Qt is a mix of C and C++ and as such there is one solid point - "main" function.
                        Than one can go UP the chain - to find "#include x.h" for "main".
                        Than the fun starts with main instance of QApplication app(argc, argv); class and other classes , where the "meat and potatoes" of the project reside . Eventually "app" gets executed.

                        Now "the other classes" can be Qt , QtDesigenr etc.
                        With QtDesigenr we get x.h , x,ui , ui-x.h etc with well defined relations but "do your best guess" how it all fits together.

                        The we have x.pro and that is mystery how it fits.
                        Not mentioning "make" "qmake" compiler...

                        Enough rant.
                        If the examples projects were not created using "ui automation wizard" to build "slots" the Qt form designer is pretty useless to find them. .
                        (Yes I did read that part -see missing "Ui::xxx ")

                        I did find the btscanner uses "connect" function and hopefully I can decipher how that works .

                        It looks as I can modify current class/ classes to include inheritance of "UI" class. Or create new class and inherit form "UI -less" original class and add "UI " . Just another layer of code.

                        Question
                        Does QtCreator has means to display "inheritance tree " stricture ?
                        Probably.

                        Chris KawaC Offline
                        Chris KawaC Offline
                        Chris Kawa
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @AnneRanch said:

                        Does QtCreator has means to display "inheritance tree " stricture ?

                        Place cursor on a type and go to Tools -> C++ -> Open type hierarchy, or use a shortcut: Ctrl+Shift+T. It will open a type hierarchy pane.

                        1 Reply Last reply
                        3

                        • Login

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