Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. where is my C code?
Forum Updated to NodeBB v4.3 + New Features

where is my C code?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
12 Posts 5 Posters 1.3k 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

    After muddling thru add of new "connect" using "Signal and slot editor " in QtDesigner I am trying to physically verify results in my C code .

    Any suggestion how ? (search for added "action" ?)

    fa728a77-7ac5-4694-9abe-e855e7f98f6f-image.png

    PS
    Unless it is "automatic" (?) I have not found the actual "save added " by ..........

    Christian EhrlicherC 1 Reply Last reply
    0
    • A Anonymous_Banned275

      After muddling thru add of new "connect" using "Signal and slot editor " in QtDesigner I am trying to physically verify results in my C code .

      Any suggestion how ? (search for added "action" ?)

      fa728a77-7ac5-4694-9abe-e855e7f98f6f-image.png

      PS
      Unless it is "automatic" (?) I have not found the actual "save added " by ..........

      Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      @AnneRanch There is no c code anywhere. As you already know uic.exe creates the ui_<foo>.h file out of the <foo>.ui file which contains the corresponding c++ code.

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

      A 1 Reply Last reply
      3
      • Christian EhrlicherC Christian Ehrlicher

        @AnneRanch There is no c code anywhere. As you already know uic.exe creates the ui_<foo>.h file out of the <foo>.ui file which contains the corresponding c++ code.

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

        @Christian-Ehrlicher ...now you tell me that "connect" is in yet another place - to maintain.
        Nice .
        Especially when such place is NOT accessible (directly) via Project view.
        So what is expected, if any , way to debug // verify the QtDesigner " signal and slot editor " actual code ?

        I can verify simple "generate SIGNAL and change state of "
        radio button" in SAME object. Big deal...

        PS
        I obviously should not tell you how to express yourself , but in the future I would appreciate NOT teling me what I know... it sounds like you are grading my knowledge. But you are free to ignore my request.

        Christian EhrlicherC JonBJ 2 Replies Last reply
        0
        • A Anonymous_Banned275

          @Christian-Ehrlicher ...now you tell me that "connect" is in yet another place - to maintain.
          Nice .
          Especially when such place is NOT accessible (directly) via Project view.
          So what is expected, if any , way to debug // verify the QtDesigner " signal and slot editor " actual code ?

          I can verify simple "generate SIGNAL and change state of "
          radio button" in SAME object. Big deal...

          PS
          I obviously should not tell you how to express yourself , but in the future I would appreciate NOT teling me what I know... it sounds like you are grading my knowledge. But you are free to ignore my request.

          Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @AnneRanch said in where is my C code?:

          So what is expected, if any , way to debug // verify the QtDesigner " signal and slot editor " actual code ?

          As I already said - compile the ui file with uic and look into the generated header file.

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

            @Christian-Ehrlicher ...now you tell me that "connect" is in yet another place - to maintain.
            Nice .
            Especially when such place is NOT accessible (directly) via Project view.
            So what is expected, if any , way to debug // verify the QtDesigner " signal and slot editor " actual code ?

            I can verify simple "generate SIGNAL and change state of "
            radio button" in SAME object. Big deal...

            PS
            I obviously should not tell you how to express yourself , but in the future I would appreciate NOT teling me what I know... it sounds like you are grading my knowledge. But you are free to ignore my request.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @AnneRanch
            Not sure what you are asking or looking for. But if you are asking: when I do a signal-slot connection in Creator/Designer does it generate an explicit connect(...) statement the answer it does NOT, so if you search anywhere for that you will not find it.

            TL;DR: There is no explicit connect() statement produced in any code. Instead the generated ui_...h file calls void QMetaObject::connectSlotsByName(QObject *object) to do the connect()s "behind the scenes", by object name and method name spelling.

            • Everything you do in Designer goes into the saved .ui file, nowhere else. By all means look at it in a text editor. This includes any signal-slots you set up. In https://forum.qt.io/topic/155704/how-to-use-cascaded-connect/4 @Pl45m4 answered that in the .ui file it just produces:
               <sender>pushButton</sender>
               <signal>clicked()</signal>
               <receiver>MainWindow</receiver>
               <slot>Test()</slot>
            

            Just that. Note that there is no connect() statement.

            • Everything that is in the .ui file gets turned into code by uic in file name ui_....h, in the build output directory, nowhere else. By all means look at it in a text editor. Even then for Designer signal/slot connections it does NOT generate an explicit connect(...) statement, which you would do if you wrote it yourself. Instead it does two things:
            1. It generates a method with name ClassName::on_<objectname>_<signal>(), so MainWindow::on_pushButton_clicked() for above example.
            2. It generates code (at the end of setupUi()) which calls connectSlotsByName(). This is the "magic" function which does the connect()s, in internal Qt code which you cannot see:

            Searches recursively for all child objects of the given object, and connects matching signals from them to slots of object that follow the following form:

            void on_<object name>_<signal name>(<signal parameters>);

            I trust that is as clear as anyone can explain it. As I say, if you are looking for an explicit connect() statement anywhere for the signals-slots you set up from Designer you simply won't find one. It just relies on the actual spelling of the slot name and the call to connectSlotsByName().

            This is also one of the many reasons why Designer's signal-slot connections are fragile and not recommended for "serious" development. A simple change like altering a widget's name, or other things, can "break" this name-relationship and cause a connection not to be set up by connectSlotsByName().

            Finally, it is not possible to "physically verify results in my C code" that your Designer signal-slot is correct. Because it does not do an explicit connect() but relies instead on naming of widgets and slot function.

            Pl45m4P 1 Reply Last reply
            2
            • JonBJ JonB

              @AnneRanch
              Not sure what you are asking or looking for. But if you are asking: when I do a signal-slot connection in Creator/Designer does it generate an explicit connect(...) statement the answer it does NOT, so if you search anywhere for that you will not find it.

              TL;DR: There is no explicit connect() statement produced in any code. Instead the generated ui_...h file calls void QMetaObject::connectSlotsByName(QObject *object) to do the connect()s "behind the scenes", by object name and method name spelling.

              • Everything you do in Designer goes into the saved .ui file, nowhere else. By all means look at it in a text editor. This includes any signal-slots you set up. In https://forum.qt.io/topic/155704/how-to-use-cascaded-connect/4 @Pl45m4 answered that in the .ui file it just produces:
                 <sender>pushButton</sender>
                 <signal>clicked()</signal>
                 <receiver>MainWindow</receiver>
                 <slot>Test()</slot>
              

              Just that. Note that there is no connect() statement.

              • Everything that is in the .ui file gets turned into code by uic in file name ui_....h, in the build output directory, nowhere else. By all means look at it in a text editor. Even then for Designer signal/slot connections it does NOT generate an explicit connect(...) statement, which you would do if you wrote it yourself. Instead it does two things:
              1. It generates a method with name ClassName::on_<objectname>_<signal>(), so MainWindow::on_pushButton_clicked() for above example.
              2. It generates code (at the end of setupUi()) which calls connectSlotsByName(). This is the "magic" function which does the connect()s, in internal Qt code which you cannot see:

              Searches recursively for all child objects of the given object, and connects matching signals from them to slots of object that follow the following form:

              void on_<object name>_<signal name>(<signal parameters>);

              I trust that is as clear as anyone can explain it. As I say, if you are looking for an explicit connect() statement anywhere for the signals-slots you set up from Designer you simply won't find one. It just relies on the actual spelling of the slot name and the call to connectSlotsByName().

              This is also one of the many reasons why Designer's signal-slot connections are fragile and not recommended for "serious" development. A simple change like altering a widget's name, or other things, can "break" this name-relationship and cause a connection not to be set up by connectSlotsByName().

              Finally, it is not possible to "physically verify results in my C code" that your Designer signal-slot is correct. Because it does not do an explicit connect() but relies instead on naming of widgets and slot function.

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

              @JonB

              I don't think that any of these explanations, either here not in the other topic, will lead somewhere -.-'
              OP already knows how to write the connect statement herself, but still sticks to the (bad and limited) QtDesigner "coding"... and is then wondering and ranting that some things don't work (which never will by design).


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

              ~E. W. Dijkstra

              A 2 Replies Last reply
              0
              • Pl45m4P Pl45m4

                @JonB

                I don't think that any of these explanations, either here not in the other topic, will lead somewhere -.-'
                OP already knows how to write the connect statement herself, but still sticks to the (bad and limited) QtDesigner "coding"... and is then wondering and ranting that some things don't work (which never will by design).

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

                @Pl45m4 I may have neglected mentioning ONE part of the task - the signal ( as in generic term, not SIGNAL as defined by Qt) originates from QMainWindow "menu (bar) ".
                There it is termed as "action" , but its function is still same as PLAIN "connect".

                In my view this all boils down to establish some logical way of following and finishing the task - from source to sink/load , and the descriptions used in various doc just does not make it logical to follow the flow from one tool to another.

                1 Reply Last reply
                0
                • Pl45m4P Pl45m4

                  @JonB

                  I don't think that any of these explanations, either here not in the other topic, will lead somewhere -.-'
                  OP already knows how to write the connect statement herself, but still sticks to the (bad and limited) QtDesigner "coding"... and is then wondering and ranting that some things don't work (which never will by design).

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

                  @Pl45m4 said in where is my C code?:

                  but still sticks to the (bad and limited) QtDesigner "coding"... and is then wondering and ranting that some things don't work (which never will by design).

                  I am offended , just kidding, but dare you to send this to Alex.

                  It all does work , once one gets pass the UNDOCUMENTED " "click this to get that " ...

                  My uneducated guess is - Qt inc have no way to make sure "linked documents " follow some kind of common path.
                  As far as I can tell, this discussion , based on "callback AKA SIGNAL/ SLOT" shows that very clearly.
                  Life would be boring if it all works " out of the box"...

                  Pl45m4P 1 Reply Last reply
                  0
                  • A Anonymous_Banned275

                    @Pl45m4 said in where is my C code?:

                    but still sticks to the (bad and limited) QtDesigner "coding"... and is then wondering and ranting that some things don't work (which never will by design).

                    I am offended , just kidding, but dare you to send this to Alex.

                    It all does work , once one gets pass the UNDOCUMENTED " "click this to get that " ...

                    My uneducated guess is - Qt inc have no way to make sure "linked documents " follow some kind of common path.
                    As far as I can tell, this discussion , based on "callback AKA SIGNAL/ SLOT" shows that very clearly.
                    Life would be boring if it all works " out of the box"...

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

                    @AnneRanch said in where is my C code?:

                    I may have neglected mentioning ONE part of the task - the signal ( as in generic term, not SIGNAL as defined by Qt) originates from QMainWindow "menu (bar) ".
                    There it is termed as "action" , but its function is still same as PLAIN "connect".

                    A signal is a signal and an action is an action.
                    A QAction fires a signal like QAction::triggered upon activation (e.g. you click the action widget button associated with your menuBar action). Then you can connect a function / slot to that signal.
                    I don't understand why most Qt users think Qt is well documentated, while you always think it's not...

                    @AnneRanch said in where is my C code?:

                    It all does work , once one gets pass the UNDOCUMENTED " "click this to get that " ...

                    Yes, there is room for improvements in QtDesigner, but, actually, nobody uses this s#!%t, because it's more or less a demo feature.
                    You can't put these tightly to the objectname coupled, "no code" connections in real code. Everything will break once you rename or re-organize something.
                    And even if someone, who knows C++ well, but doesn't know Qt, reads your code using the "connect(....)" statement, one will still understand what's going on and why things happen.
                    But these "behind-the-scene" connections made by QtDesigner and setup by QMetaObject::connectSlotsByName in auto-connection manner, are a plain to track down, if you don't know that they exist.
                    And that's just one of (many many) other cases, where you shouldn't "write" your program by clicking buttons in QtDesigner.

                    I think you've learned something out of all these topics in all these years here in the forum... and you are still working on the same project.
                    My well-meant advice:
                    Go through your code (your "UIs") and start to write a connect-statement for every connection. It's just one line. Then you can get rid of all that bs integrated in your UI files, which will come to its limits and where you, at some point, just can't do stuff (by design) anymore.
                    If you want to use QtDesigner to "design" (drag widgets around) your GUI, fine. It's a valid alternative over creating simple widgets and layouts by code.
                    But trying to code as less as possible and abusing QtDesigner "features" as much as possible won't work all the time, as you might have noticed.
                    You know the basic things and how to code (as it has already been explained to you several times)

                    As the Nike slogan says: Just do it ;-)
                    Trust me, it will pay off.
                    Over and out. ;-)

                    Edit:

                    So that this post does not remain more or less off-topic, the answer to the question in the title is: Nowhere, there is no code.


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

                    ~E. W. Dijkstra

                    S 1 Reply Last reply
                    1
                    • Pl45m4P Pl45m4

                      @AnneRanch said in where is my C code?:

                      I may have neglected mentioning ONE part of the task - the signal ( as in generic term, not SIGNAL as defined by Qt) originates from QMainWindow "menu (bar) ".
                      There it is termed as "action" , but its function is still same as PLAIN "connect".

                      A signal is a signal and an action is an action.
                      A QAction fires a signal like QAction::triggered upon activation (e.g. you click the action widget button associated with your menuBar action). Then you can connect a function / slot to that signal.
                      I don't understand why most Qt users think Qt is well documentated, while you always think it's not...

                      @AnneRanch said in where is my C code?:

                      It all does work , once one gets pass the UNDOCUMENTED " "click this to get that " ...

                      Yes, there is room for improvements in QtDesigner, but, actually, nobody uses this s#!%t, because it's more or less a demo feature.
                      You can't put these tightly to the objectname coupled, "no code" connections in real code. Everything will break once you rename or re-organize something.
                      And even if someone, who knows C++ well, but doesn't know Qt, reads your code using the "connect(....)" statement, one will still understand what's going on and why things happen.
                      But these "behind-the-scene" connections made by QtDesigner and setup by QMetaObject::connectSlotsByName in auto-connection manner, are a plain to track down, if you don't know that they exist.
                      And that's just one of (many many) other cases, where you shouldn't "write" your program by clicking buttons in QtDesigner.

                      I think you've learned something out of all these topics in all these years here in the forum... and you are still working on the same project.
                      My well-meant advice:
                      Go through your code (your "UIs") and start to write a connect-statement for every connection. It's just one line. Then you can get rid of all that bs integrated in your UI files, which will come to its limits and where you, at some point, just can't do stuff (by design) anymore.
                      If you want to use QtDesigner to "design" (drag widgets around) your GUI, fine. It's a valid alternative over creating simple widgets and layouts by code.
                      But trying to code as less as possible and abusing QtDesigner "features" as much as possible won't work all the time, as you might have noticed.
                      You know the basic things and how to code (as it has already been explained to you several times)

                      As the Nike slogan says: Just do it ;-)
                      Trust me, it will pay off.
                      Over and out. ;-)

                      Edit:

                      So that this post does not remain more or less off-topic, the answer to the question in the title is: Nowhere, there is no code.

                      S Offline
                      S Offline
                      SimonSchroeder
                      wrote on last edited by
                      #10

                      @Pl45m4 said in where is my C code?:

                      So that this post does not remain more or less off-topic, the answer to the question in the title is: Nowhere, there is no code.

                      Even though you can rely on connectSlotsByName, the screenshot in the original post shows using the Signals and Slots Editor. In that case I agree with @Christian-Ehrlicher that there should be C++ code in the ui_<foo>.h file after running uic.exe on the corresponding ui file.

                      Pl45m4P 1 Reply Last reply
                      0
                      • S SimonSchroeder

                        @Pl45m4 said in where is my C code?:

                        So that this post does not remain more or less off-topic, the answer to the question in the title is: Nowhere, there is no code.

                        Even though you can rely on connectSlotsByName, the screenshot in the original post shows using the Signals and Slots Editor. In that case I agree with @Christian-Ehrlicher that there should be C++ code in the ui_<foo>.h file after running uic.exe on the corresponding ui file.

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

                        @SimonSchroeder

                        But that's nothing you can really use or modify since it's generated and overwritten when you change something.
                        I think the whole topic was about the question why QtDesigner can't put a connect(......), for example in your MainWindow class


                        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
                        0
                        • Pl45m4P Pl45m4

                          @SimonSchroeder

                          But that's nothing you can really use or modify since it's generated and overwritten when you change something.
                          I think the whole topic was about the question why QtDesigner can't put a connect(......), for example in your MainWindow class

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

                          @Pl45m4 This "discussion" did provide SOME help in implementing / tracking basic SIGNAL / SLOT (concept) as defined by Qt.
                          And I do appreciate that.

                          However, it got diverted off the original post and is no longer of (any) help TO ME personally.

                          It is up to the forum users to continue with various speculations and terminology variations.

                          I am "over and out "....

                          1 Reply Last reply
                          0
                          • Pl45m4P Pl45m4 referenced this topic on

                          • Login

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