Composing forms with forms?
-
Hi all,
I'm trying out Qt to develop some software that will be moderate in size and complexity. One of the things that I like to do with UIs is to first create the groups of components that will be common to several places in the application, such as a navigation cluster, information area, history summary, etc. Those are simply small aggregations of widgets and their functionality that will be common on multiple pages of the application, since the formatting and function needs to be the same. Why duplicate all that in multiple places, right? So I created some forms in Qt Creator that I would like to be able to "drop into" various pages. And then I noticed that the ability to do that type of drop in seems to be missing from Qt creator. I managed to do it purely programmatically, which is nice, but then I lose the lovely ability to use Qt Creator's real value ads like the Action Editor, Signals and Slots Editor, editing tab order, etc. This seems like very, very basic, C++ reuse style functionality and perhaps I'm simply unaware how to carry out at the moment. Could someone point me to it if I'm simply missing it?
Thank you in advance,
-Eric
-
Hi @JonB ,
If I open Qt Designer, it looks like the graphical composing subset of Qt Creator that I use to graphically compose the *.ui files used for forms and such. I am assuming that Qt Creator USES Qt Designer for this purpose. Is that assumption incorrect?
Thank you,
-Eric
-
@eprincen
Indeed, that is called Designer. You posted into a sub-forum for Design Studio, which is not the same thing. I see an administrator has moved your topic from there now, that's fine.I love Qt for the facilities it provides, but (IMHO) Designer is not the most sophisticated. I have used MS Visual Studio in the past, and I have to say Designer is not as good as that, so you may have to temper your expectations.
There are two ways you can "include" separately-designed widgets/pages into a parent at design-time:
-
Search the docs for "Promote". This allows a simple replacement of a widget class with one you have derived from that class. I think you then only get to edit the same attributes as the base class offers.
-
Search the docs for "Custom Widget". This allows you to design a widget with its own design-time attributes available, but it is quite a bit more work to create and integrate.
Personally I have never used either of these. I use separate
.ui
files to design widgets/pages which will be included at runtime. Then I load those up at runtime, but I only place some "placeholder" in the parent page at design-time.As for the "features" you like/would miss in Designer. I have never had to alter the tab order of anything I designed anyway. For the actions/signals/slots, while they might look convenient/useful they really do not do much. Most of us never use them in Designer, you will find over time that specifying explicit
connect()
s in code is just more flexible.That's my 2 cents. Others might have different views.
-