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. Best way to reuse forms(or ui design) in a project [SOLVED]
QtWS25 Last Chance

Best way to reuse forms(or ui design) in a project [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 6.7k 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.
  • L Offline
    L Offline
    lijo
    wrote on 11 Jun 2012, 07:09 last edited by
    #1

    I am creating 10 different forms. All of them have a common header and footer. Header will have the same background image but different titles for different forms. Footer is also similar in concept. I would like to make the header and footer design only once and reuse them in all the forms. I should be able to set some properties like title from individual forms(or the associated implementation class). And if I make some design changes(like an extra label) later in header, it should be reflected on individual forms.
    Also I would like to do all the ui design using QtCreator.

    From my understanding so far, I can think of following possible solutions.

    1. Inherit from a class implementing the common form design.

      • I will not be able to use QtCreator for designing child forms.
    2. Create a template with header & footer and use the template for creating forms.

      • Any later change in header design will not be reflected on the forms
    3. Create custom widgets for header and footer. Integrate with QtCreator and use in individual forms.

      • Relatively complex and some extra overhead.

    Since I am new to Qt, I am not sure which is the best way to go ahead or there are other options(Qt way!) available. Would any one help me on this? Any help would be appreciated.

    Thanks,
    -lijo

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tucnak
      wrote on 11 Jun 2012, 07:25 last edited by
      #2

      In my opinion, the best way - to create patterns and include it from all your forms.

      Create QWidget class which will represent your header

      Add it from your form. As example: ui->layout->addWidget(new Header());

      ...

      PROFIT!!1

      Undderstood?

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lijo
        wrote on 11 Jun 2012, 07:41 last edited by
        #3

        Thanks for the quick response!

        bq. 2. Add it from your form. As example: ui->layout->addWidget(new Header());

        This is much better and easier(Qt way!)

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tucnak
          wrote on 11 Jun 2012, 07:47 last edited by
          #4

          It's not Qt-way)) - it's logic way. In dev it called ui templates (you can change one widget and other widgets will change their state).

          P.S.
          @
          thread.setName(thread.name().append("[SOLVED] "));
          thread.update();
          @

          1 Reply Last reply
          0
          • D Offline
            D Offline
            David_Gil
            wrote on 11 Jun 2012, 08:00 last edited by
            #5

            I would bet on making a custom QWidget. The constructor could also accept a QString for the title.

            Chapter 5 of 'C++ GUI Programming With Qt 4' is dedicated to custom widgets. A must-have book, anyway.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lijo
              wrote on 11 Jun 2012, 11:50 last edited by
              #6

              Thanks for the suggestions. I will go ahead with custom widget approach(with QtCreator plugin). Integration with QtCreator is very useful for me, as I will be doing lot of experiments with design.

              1 Reply Last reply
              0

              4/6

              11 Jun 2012, 07:47

              • Login

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