Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to define extra signals and slots of a widget/object when using a *ui file and the designer ?
Qt 6.12 LTS is out! See what's new in the release blog

How to define extra signals and slots of a widget/object when using a *ui file and the designer ?

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 5.5k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Adding them(declarations) to the header file and the definition to the .cpp file didn't work.

    So I found that they can be declared by < Right-click->Change Signals/Slots > menu within the designer.

    But I can't find any way to define what happens when they are used.(It as expected, doesn't show errors ).

    How is it done best ?

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      Don't know if it's best, but I'd try right clicking on a widget, then "Go to slot...". If this option doesn't suit you, you can always delete the changes made to .cpp & .h, and no harm done :D*

      *almost no harm XD

      --

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Something strange happened when I tried that.

        In Change Signals/Slots...I specified a slot "relay(QString)" and a signal "emit_string(QString)" .
        (with the intention that another object will invoke the slot which in turn emits a signal....after modifying the string a little)

        But whenever I visit the Go to Slot menu...the options present there allow me to select the signals only....and when I select the signal, it gets added in the source files as slots.. :S

        Any explanation of this seemingly weird scenario ?

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

          You have to make your implementations in your own code. Qt Designer can be used to help you, but it is not a tool that can write your whole program.

          What you are trying to do is outside of the scope of Qt Designer.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            [quote author="Andre" date="1311685832"]You have to make your implementations in your own code. Qt Designer can be used to help you, but it is not a tool that can write your whole program.

            What you are trying to do is outside of the scope of Qt Designer. [/quote]

            I tried to put the declarations and implementations in the source files myself, but they do not respond to the connect(...) calls ..i.e..they aren't found at runtime, when the rest of the details are in the xml/ui file.

            I think that some identifiers are modified(by the moc perhaps?) but can't find any documentation for that..

            1 Reply Last reply
            0
            • ? This user is from outside of this forum
              ? This user is from outside of this forum
              Guest
              wrote on last edited by
              #6

              Mmm... what about letting QtDesigner reparse the project? (just quit & restart QtDesigner). Also, what are "the rest of the details"? I mean, you can define your source, headers & calls... what else do you need?

              --

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                [quote author="iytenorio" date="1311687066"]Mmm... what about letting QtDesigner reparse the project? (just quit & restart QtDesigner). Also, what are "the rest of the details"? I mean, you can define your source, headers & calls... what else do you need?

                --[/quote]
                Err...what do you mean?
                Rest of the details means that I've made the whole interface using Designer, for a frontend a standard C++ program of mine....thus everything ..geometry, signals and slots, connect()s..everything is within the xml like ui file....which does not seem to recognize the signal/slots defined the normal way..(MAYBE I've to take an extra step ?)

                Also, restarting did not change anything.

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

                  You simply can not make the connects to custom slots from Designer. You can only connect signals and slots that are known to Designer. That is: the standard ones provided by the widgets you are using. Any signals or slots that you declare and implement yourself on the form, can not be used from designer but must be connected manually from code.

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    [quote author="Andre" date="1311687993"]You simply can not make the connects to custom slots from Designer. You can only connect signals and slots that are known to Designer. That is: the standard ones provided by the widgets you are using. Any signals or slots that you declare and implement yourself on the form, can not be used from designer but must be connected manually from code. [/quote]

                    Fair enough...
                    ..but I think that the apparently 'broken' feature which tempts newcomers like me should not be included into a stable version.

                    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
                    • Unsolved