I am new to
QT Qt(4) and very excited to begin programming. I have 6 years VB programming background and < 1 year C++.
I work on a Linux Box using
QT Qt Designer and Gedit :)
I am getting into the C and
QT Qt Jargon but I am having trouble finding the right documentation for several subjects.
My question: How do I program the following relationships in
Form-A has a menu and a tool bar. When a menu-item is clicked I’d like Form-B to be displayed inside form-A. Form-B is a form hosting form-C, form-D, and form-E. (like in an HTML Frame where you load multiple .html files inside a mainform.html).
Please consider the following in your answer:
- I do not want to use MDI.
- I really want to use a separate form for each layout and not 1 big main form with hiding panels and layouts
- When opening multiple forms inside an opened form I need to be able to pass data (as delegate I guess) (in)between the forms. For example: A button click in form-D causes data to be loaded in form-E from a SQL database. Form-D and form-E are part of form-B. Form B was loaded inside form-A…
Thank you, you help is appreciated.
I think you should implement each form as a separate widget and use a qstackedlayout [doc.qt.nokia.com] as the layout for the main window. In this way only one widget will be visible at a time.
You may also be interested in the convenient QStackedWidget.
To pass messages, delegates are not the way to go. A delegate is used for rendering content in an item view. Instead, you should read about using signals and slots [developer.qt.nokia.com] .
To prevent futher communication issues, what you call a form is called a widget in Qt lingo. A top-level widget is shown as a window on your system, and is sometimes called a form. All visible elements are widgets: buttons, text edits, forms and tabs, but also complete dialogs and main windows.
Thanks for your quick reply.
I see – every form is to be made into a widget ?!?
I should then host multiple widgets on 1 base form which in itself is a widget (container).
Yes, the idea is that. You can stack widget one within the other to achieve much more complex widgets (forms). Then you can even stack them together using a stack layout into a one big container.
As Andre said, each widget can emit and handle signals, which can be thought as the equivalent of an event. So a button in your form A can emit a clicked signal that can be handled by your form B to load additional data and the save action on form B can cause a refresh back to forms A and C…..and so on.