Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Parent/Child Forms
Forum Update on Monday, May 27th 2025

Parent/Child Forms

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    m3rlin
    wrote on last edited by
    #1

    HI,

    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 -QT- Qt/C++?

    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.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fluca1978
      wrote on last edited by
      #2

      I think you should implement each form as a separate widget and use a "qstackedlayout":http://doc.qt.nokia.com/latest/qstackedlayout.html as the layout for the main window. In this way only one widget will be visible at a time.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        You may also be interested in the convenient [[doc: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":http://developer.qt.nokia.com/doc/qt-4.7/signalsandslots.html .

        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.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          m3rlin
          wrote on last edited by
          #4

          fluca1978,

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

          Aha...

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fluca1978
            wrote on last edited by
            #5

            [quote author="m3rlin" date="1322731193"]fluca1978,

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

            Aha...[/quote]

            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.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              m3rlin
              wrote on last edited by
              #6

              @Andre and fluca1978,

              I am loving it already...
              Thank you both.

              I will get the jargon right soon! Takes a while to "signal" from 1 braincell widget to the other :)

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved