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. [SOLVED]How to promote QMdiArea in designer?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]How to promote QMdiArea in designer?

Scheduled Pinned Locked Moved General and Desktop
21 Posts 3 Posters 12.2k 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.
  • M Offline
    M Offline
    mbnoimi
    wrote on last edited by
    #6

    [quote]What error messages do you get?[/quote]
    Nothing just I noticed that promoting process didn't done because I didn't get "Demote to <QtClass>" just like any other class.

    PS
    Could you please test Promote process on [url=http://www.mediafire.com/file/9rebbbdumq982df/MDITest.zip]this[/url] project (it's tiny project)

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #7

      You can put a QFrame on your form instead of a QMdiArea, right click it and promote the QFrame to your mdiArea class.
      The Qframe will act as a placeholder in Qt Designer, but when compiling it will be considered a midArea.

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • EddyE Offline
        EddyE Offline
        Eddy
        wrote on last edited by
        #8

        i tested it myself and it works.

        I had to do some minor changes in your code :
        in MainWindow constructor :

        @// ui->frame = new MdiArea(QImage(":/img/gnome-graphics.png"), Qt::red);
        ui->frame->addSubWindow(new MdiArea(QImage(":/img/gnome-graphics.png"), Qt::red));@

        in MdiArea class I added a default constructor which is needed by moc

        @ MdiArea(QWidget * parent = 0)
        {
        i = QImage(":/img/gnome-graphics.png");
        b = Qt::yellow;
        }@

        Of course it will not be exactly what you want. My purpose was to test the approach explained above with your class.

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mbnoimi
          wrote on last edited by
          #9

          [quote]i tested it myself and it works.[/quote]
          I tried it for QFrame but it didn't work for me so could you please upload your modified project?

          Designer didn't accept to Promote QMdiArea for QFrame base class!!!

          1 Reply Last reply
          0
          • EddyE Offline
            EddyE Offline
            Eddy
            wrote on last edited by
            #10

            Those lines I mentioned are the only ones that I changed.

            bq. Designer didn’t accept to Promote QMdiArea for QFrame base class!!!

            I think your problem is here : I see that you tried to use QMdiArea, but as you can see in my example I use your MdiArea class instead.

            For completeness : here are the choices I made in the "promoted Widgets" dialogbox. You won't see that in the project if I send it to you.

            Base Class name : QFrame
            Promoted class name : MdiArea
            header file : mdiarea.h

            click button "Add" and then click button "Promote"

            That's it.

            EDIT : if you still need the altered project. just let me know.

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mbnoimi
              wrote on last edited by
              #11

              [quote]I think your problem is here : I see that you tried to use QMdiArea, but as you can see in my example I use your MdiArea class instead.
              .
              .
              .
              Base Class name : QFrame
              Promoted class name : MdiArea
              header file : mdiarea.h
              click button “Add” and then click button “Promote”
              [/quote]
              No no, I did the same steps but the last one doesn't exist (while it works for other classes)

              1 Reply Last reply
              0
              • EddyE Offline
                EddyE Offline
                Eddy
                wrote on last edited by
                #12

                bq. I did the same steps but the last one doesn’t exist

                What do you mean exactly? is the Add button grayed out or the Promote button? Do you get an error message?

                Qt Certified Specialist
                www.edalsolutions.be

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mbnoimi
                  wrote on last edited by
                  #13

                  [quote]is the Add button grayed out or the Promote button?[/quote]
                  Promote button grayed out.

                  See this screenshot please:
                  http://img705.imageshack.us/img705/3389/screenshot1oy.jpg

                  PS
                  Do you think it's betten to send you screencast?

                  1 Reply Last reply
                  0
                  • EddyE Offline
                    EddyE Offline
                    Eddy
                    wrote on last edited by
                    #14

                    bq. Promote button grayed out.
                    See this screenshot please:

                    that's normal
                    You have to fill in the dialogbox first than the Add button gets available and after that the promote button can be used.
                    I explained this already, did you do it like that?

                    bq. For completeness : here are the choices I made in the “promoted Widgets” dialogbox. You won’t see that in the project if I send it to you.
                    Base Class name : QFrame
                    Promoted class name : MdiArea
                    header file : mdiarea.h
                    click button “Add” and then click button “Promote”

                    EDIT : missed it that you already created it. just select what you alread made and then the button should be available

                    Qt Certified Specialist
                    www.edalsolutions.be

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mbnoimi
                      wrote on last edited by
                      #15

                      [quote]just select what you alread made and then the button should be available[/quote]
                      I selected it. It still unavailable!!!!

                      I'll upload a sceencast to see what's going on

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mbnoimi
                        wrote on last edited by
                        #16

                        cold you please see the following screencast
                        http://eng-svu.al-yarmook.com/MdiArea/

                        1 Reply Last reply
                        0
                        • EddyE Offline
                          EddyE Offline
                          Eddy
                          wrote on last edited by
                          #17

                          You used a QMdiArea as the place holder. It should be a QFrame in Qt Designer because you subclass QFrame.
                          !http://dl.dropbox.com/u/33544011/MdiArea.PNG(Have a look at this screenshot)!

                          Qt Certified Specialist
                          www.edalsolutions.be

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            mbnoimi
                            wrote on last edited by
                            #18

                            [quote]You used a QMdiArea as the place holder. It should be a QFrame in Qt Designer because you subclass QFrame.[/quote]
                            Does it mean I've to morph QMdiArea to QFrame?! If yes this is huge disaster to me because I created many widgets in subwindows by Designer so I've to use really QMdiArea instead of QFrame.

                            Do you've any solution?

                            1 Reply Last reply
                            0
                            • EddyE Offline
                              EddyE Offline
                              Eddy
                              wrote on last edited by
                              #19

                              bq. Does it mean I’ve to morph QMdiArea to QFrame?! If yes this is huge disaster to me because I created many widgets in subwindows by Designer so I’ve to use really QMdiArea instead of QFrame.

                              Yes you have to use a QFrame and add the subwindows in code. That's not so much work. If you have made a class with ui, you can use Designer to make the visual appearance of the widgets you want to use in the MdiArea..

                              I tested it with your own MdiArea, but it can be anything...

                              @// ui->frame = new MdiArea(QImage(":/img/gnome-graphics.png"), Qt::red);
                              ui->frame->addSubWindow(new MdiArea(QImage(":/img/gnome-graphics.png"), Qt::red));
                              ui->frame->addSubWindow(new MdiArea(QImage(":/img/gnome-graphics.png"), Qt::green));@

                              Qt Certified Specialist
                              www.edalsolutions.be

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                mbnoimi
                                wrote on last edited by
                                #20

                                Thanks a lot guys I fixed this issue by:
                                @QList<QMdiSubWindow *> windows = ui->mdiArea->subWindowList();
                                qDebug("%d", windows.count());
                                for (int var = 0; var < windows.count(); ++var) {
                                QMdiSubWindow *wind = windows[var];
                                ui->frame->addSubWindow(wind->widget());
                                }
                                ui->mdiArea->setVisible(0);@

                                1 Reply Last reply
                                0
                                • EddyE Offline
                                  EddyE Offline
                                  Eddy
                                  wrote on last edited by
                                  #21

                                  Glad you made it!

                                  Please could you edit your title and add [Solved] in front of it?

                                  Also use @ instead of /[code/] to mark code in your topic. I changed it for you. (see the <> button on top of the editor.

                                  Qt Certified Specialist
                                  www.edalsolutions.be

                                  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