PDA

View Full Version : Promoting the parent QWidget of a QWidget form



extrakun
5th June 2009, 09:55
Hi,

I am current creating a custom widget of my own, derived from QWidget. I am trying to create the UI elements for it in QT Designer but I couldn't promote the topmost QWidget at all (I have to add another QWidget and promote that instead). Is it possible to promote the main/topmost QWidget to my custom widget?

Regards,
Kun

wysota
7th June 2009, 09:15
It wouldn't do you any good. Just setup the component on an appropriate subclass of QWidget when calling setupUi() in your code.

mingodad
16th April 2010, 10:20
I don't agree with the answer to this question !

It's perfectly valid to want promote the top most widget, scenario:

We are designing several forms/dialogs and want all of then inherit from the basicFormDialog where we can insert all the common code and settings.

I'm looking for this functionality too and hope that it can be enabled in future versions of QTCreator !

Also the promoting idea should be usable with layouts too !

wysota
16th April 2010, 10:43
I don't agree with the answer to this question !

It's perfectly valid to want promote the top most widget, scenario:

We are designing several forms/dialogs and want all of then inherit from the basicFormDialog where we can insert all the common code and settings.

I'm looking for this functionality too and hope that it can be enabled in future versions of QTCreator !
Promoting a widget doesn't yield any benefits other than forcing uic to generate code for the promoted widget instead of its superclass. Bearing the fact that uic doesn't create the top-most widget, promoting it doesn't make any sense, the code generated by uic would be identical with the only exception that setupUi() would have a different argument type which would give no additional value considering the presence of inheritance in C++ where you can pass a subclass to a function that expects a superclass.


Also the promoting idea should be usable with layouts too !
I'm not sure how promoting a layout would work... I could understand a layout plugin but promoting a layout...?

Lesiok
16th April 2010, 11:04
I don't agree with the answer to this question !

It's perfectly valid to want promote the top most widget, scenario:

We are designing several forms/dialogs and want all of then inherit from the basicFormDialog where we can insert all the common code and settings.

I'm looking for this functionality too and hope that it can be enabled in future versions of QTCreator !

Also the promoting idea should be usable with layouts too !Just create plugin for Designer with Yours basicFormDialog and that's all.

mingodad
16th April 2010, 11:39
That is not so easy or the most usefull way to do it.

Writing a plugin isn't so easy and there is the problem of different compilers platforms.

I don't understand what it means :
-----
Promoting a widget doesn't yield any benefits other than forcing uic to generate code for the promoted widget instead of its superclass. Bearing the fact that uic doesn't create the top-most widget, promoting it doesn't make any sense, the code generated by uic would be identical with the only exception that setupUi() would have a different argument type which would give no additional value considering the presence of inheritance in C++ where you can pass a subclass to a function that expects a superclass.
----

Look at what I expect:

wysota
16th April 2010, 14:19
FormBase is derived from QWidget so you don't need to promote the form to FormBase, it can be QWidget-based without losing any functionality.

Promoting the layout doesn't make much sense as you wouldn't be able to use the added functionality in Designer anyway so it's easier to leave blank space on the form and then place the new layout in code. Otherwise you will have WYSINWYG (what you see is not what you get) semantics. You have to accept the fact you can't do everything with point & click.

Next time please attach individual files as files or as an archive of files, not as a text file containing the offending content of your post.