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. Multiple .ui forms for one class.
Forum Updated to NodeBB v4.3 + New Features

Multiple .ui forms for one class.

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 5.4k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    sweetMango
    wrote on 6 Aug 2018, 14:21 last edited by
    #1

    Hi!

    I have an class, that adds new filter to list. I want to transform the window, so it only give to user ability to edit color of filter. I have a form prepared. Is there any option to link two forms to one class, and setup it by ui->setupUI, depending on option triggered by user (Add/Edit)?

    M 1 Reply Last reply 6 Aug 2018, 15:01
    0
    • S sweetMango
      6 Aug 2018, 14:21

      Hi!

      I have an class, that adds new filter to list. I want to transform the window, so it only give to user ability to edit color of filter. I have a form prepared. Is there any option to link two forms to one class, and setup it by ui->setupUI, depending on option triggered by user (Add/Edit)?

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 6 Aug 2018, 15:01 last edited by mrjj 8 Jun 2018, 15:03
      #2

      @sweetMango
      Well you can use
      http://doc.qt.io/qt-5/quiloader.html
      to load an UI file at runtime.

      You can also use setupUI() but that depends on the ui_widgetname file as its a class with variables in
      so not sure what you want to do.

      You want to replace all widgets in a from with the widgets defines in others forms setup?

      You can do
      Ui::SomeName * ui2 = new Ui::SomeName;
      ui2->setup(this)
      To create all widgets defines in SomeName form with other widget as parent.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sweetMango
        wrote on 7 Aug 2018, 07:08 last edited by
        #3

        Actually I want to change window connected to the class, but keep this class methods and functionality. For eg.

        I have this view:
        0_1533625126807_1.png

        And I want to transform it to this:
        1_1533625126807_2.png

        Linking new Ui like: Ui::SomeName * ui2 = new Ui::SomeName; says : error: allocation of incomplete type 'Ui::EditColorWindow'

        J 1 Reply Last reply 7 Aug 2018, 07:25
        0
        • S sweetMango
          7 Aug 2018, 07:08

          Actually I want to change window connected to the class, but keep this class methods and functionality. For eg.

          I have this view:
          0_1533625126807_1.png

          And I want to transform it to this:
          1_1533625126807_2.png

          Linking new Ui like: Ui::SomeName * ui2 = new Ui::SomeName; says : error: allocation of incomplete type 'Ui::EditColorWindow'

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 7 Aug 2018, 07:25 last edited by
          #4

          @sweetMango Why don't you simply create two different widgets with designer and then put the one you currently need in your dialog? You could even use http://doc.qt.io/qt-5/qstackedwidget.html

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • S Offline
            S Offline
            sweetMango
            wrote on 7 Aug 2018, 07:37 last edited by sweetMango 8 Jul 2018, 07:39
            #5

            @jsulm This is what I want to do, but I'm not really sure how to do this. Stacking widgets looks a lil' bit too "overcomplicated".

            I thought about something like this:

            AddFilter::AddFilter(QWidget* parent, bool flag) :
                QDialog(parent),
                ui(new Ui::AddFilter)
            {
            if (flag){
                ui->setupUi(this);
                setFixedSize(471, 421);
            }
            else{
                Ui::EditColorWindow *ui2 = new Ui::EditColorWindow;
                ui2->setupUi(this);
            }
            

            but it gives me error mentioned earlier.

            J D 2 Replies Last reply 7 Aug 2018, 07:40
            0
            • S sweetMango
              7 Aug 2018, 07:37

              @jsulm This is what I want to do, but I'm not really sure how to do this. Stacking widgets looks a lil' bit too "overcomplicated".

              I thought about something like this:

              AddFilter::AddFilter(QWidget* parent, bool flag) :
                  QDialog(parent),
                  ui(new Ui::AddFilter)
              {
              if (flag){
                  ui->setupUi(this);
                  setFixedSize(471, 421);
              }
              else{
                  Ui::EditColorWindow *ui2 = new Ui::EditColorWindow;
                  ui2->setupUi(this);
              }
              

              but it gives me error mentioned earlier.

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 7 Aug 2018, 07:40 last edited by
              #6

              @sweetMango What you're trying with UI files is overcomplicated.
              There is nothing complicated with stacked widgets.
              But if you don't want to use them then take a look at http://doc.qt.io/qtcreator/creator-writing-program.html
              You simply need to create two widgets, then create and show the one you currently need.
              Sounds complicated? Use stacked widgets, should be simpler.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • S sweetMango
                7 Aug 2018, 07:37

                @jsulm This is what I want to do, but I'm not really sure how to do this. Stacking widgets looks a lil' bit too "overcomplicated".

                I thought about something like this:

                AddFilter::AddFilter(QWidget* parent, bool flag) :
                    QDialog(parent),
                    ui(new Ui::AddFilter)
                {
                if (flag){
                    ui->setupUi(this);
                    setFixedSize(471, 421);
                }
                else{
                    Ui::EditColorWindow *ui2 = new Ui::EditColorWindow;
                    ui2->setupUi(this);
                }
                

                but it gives me error mentioned earlier.

                D Offline
                D Offline
                Devopia53
                wrote on 7 Aug 2018, 07:47 last edited by Devopia53 8 Jul 2018, 07:47
                #7

                @sweetMango

                Append header: #include "ui_editcolorwindow.h in .cpp.

                1 Reply Last reply
                1
                • P Pl45m4 referenced this topic on 26 Nov 2023, 04:08

                2/7

                6 Aug 2018, 15:01

                topic:navigator.unread, 5
                • Login

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