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. [solved] Where is the glue code?
QtWS25 Last Chance

[solved] Where is the glue code?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 2.5k Views
  • 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.
  • H Offline
    H Offline
    hardcodes.de
    wrote on last edited by
    #1

    If I create a simple widget based application, that has one push button on its form. In die QtDesigner I connect the release() signal with a slot function (context menu, "go to slot").

    And the slot function simply quits:

    @void MainWindow::on_pushButton_released()
    {
    this->close();
    }@

    So far, so good, it works.

    But where do I find the glue code that connects the signal with the slot? In the .ui file there is nothing, all .h and .cpp files give no clue. There is only the function for itself and somehow it is connected (by magicg). Is there somewhere a file with the actual code or is there a hidden .xml (or whatever) file that is interpreted during runtime?

    while(!sleep){++sheep;}

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

      Nope, there is no such file. The glue you are looking for is in the _ui.h file that is generated at compile time from the .ui file.

      Note that you are probably better of making the connections between signals and slots explicitly, rather than relying on the auto-connect feature. So, in your constructor, after the setupUi() call, you expliclity put
      @
      connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(close()));
      @

      No need for a slot like you wrote, as close() already is a slot that you can connect to directly.

      1 Reply Last reply
      0
      • JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        Isn't the information in the .ui file, under a property called "connections"?

        The XML code contains both information for the widget layout, and the signal/slot connections; it's converted to C++ code first, then into binary, during compilation.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hardcodes.de
          wrote on last edited by
          #4

          @Andre: thank you! There must be still one place where the information is stored - even during compile time the compiler must know what to connect.
          But you gave me the important info: do it yourself in code ;-)

          @JKSH: that's true for connections that were made in the Slot/Connections view (F4) but not for those in the context menu, that made me so curious ;-)

          BTW: how can I mark this thread as solved?

          while(!sleep){++sheep;}

          1 Reply Last reply
          0
          • D Offline
            D Offline
            deimos
            wrote on last edited by
            #5

            bq. BTW: how can I mark this thread as solved?

            edit your first post and modify the title :)

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hardcodes.de
              wrote on last edited by
              #6

              while(!sleep){++sheep;}

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lgeyer
                wrote on last edited by
                #7

                If you really want to see the 'magic behind' feel free to take a look at "QMetaObject::connectSlotsByName":http://qt.gitorious.org/qt/qt/blobs/4.8/src/corelib/kernel/qobject.cpp#line3349, which is called from <code>setupUi</code> and automatically connects any slots following a "specific naming convention":http://qt-project.org/doc/qt-4.8/qmetaobject.html#connectSlotsByName.

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  hardcodes.de
                  wrote on last edited by
                  #8

                  That's too deep into c++ for me right now, but I may take a look in future. Thanks for the link!

                  while(!sleep){++sheep;}

                  1 Reply Last reply
                  0

                  • Login

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