Some suggestions
-
【From China】
I really want that the ui could be changed with constructe function,or the constructe function will change as the ui manually changed.They should be the in time 同步的! -
Do you have an example of what you would like to see?
-
I suspect you mean within the UI editor from/to source code, but it is not really clear what you want to achieve.
And I suspect this is not the right forum to post on it. -
Yes ,the UI editor and the source code.
Sometimes I need UI editor to add a widget, and sometimes I need to use source code,
After these, I cant see all the widgets in UI editor, which bored me a little. -
I believe this is not possible. The ui files are declarative, and do not know what is happening on the C++ side.
-
I think you want to change dinamically some widget of the app. I know that using c++ code you can create on line a list of widgets and put them in the app dinamically. But using ui editor?, I think it's only static like fluca1978 said ui are declarative.
-
In fact you have to use @setupUI@ in order to build the C++ side widgets from an XML file. I also believe that mixing the two approaches can be hard to maintain, so my suggestion is to stick with one, and in the case of ui designer, define where and initial properties of the widgets in the designer, and then change thier behavior dynamically according to the application evolution.
-
Note that
@setupUi()@
does not build the C++ side widgets from the XML file. It is just a generated function that actually constructs the GUI, but when ran, the XML (.ui) file is not used anymore. The xml is used to at compile time generate the setupUi() method, among other code. That code is then used to construct the actual GUI at runtime. -
[quote author="Andre" date="1346860206"]Note that
@setupUi()@
does not build the C++ side widgets from the XML file. It is just a generated function that actually constructs the GUI, but when ran, the XML (.ui) file is not used anymore. The xml is used to at compile time generate the setupUi() method, among other code. That code is then used to construct the actual GUI at runtime.[/quote]Thanks for the details, I knew that but mis-explained by myself. I meant that setupUI initializes widgets as from the manual C++ side (that is as the developer could do using pure C++). What I as not aware of was that the setupUI method was generated during the compile time from XML, I thought it was still accessing the XML.
-
It is sometimes enlightening to open and read the generated code. In this case, take a look inside the generated ui.h file. The moc.cpp files are also interesting, but a bit harder to understand.