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



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



  • 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

    --



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



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



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.