Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Display QMainwWindow and QMdiArea
Qt 6.12 LTS is out! See what's new in the release blog

[Solved] Display QMainwWindow and QMdiArea

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 12.7k 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.
  • F Offline
    F Offline
    Franzk
    wrote on last edited by
    #2

    QMdiArea::addSubWindow() returns a QMdiSubWindow. Do your resizing on that instead of the QWidget. You can probably also set the size of the widget before you add it to the mdi area. That will initialize the QMdiSubWindow with the correct size.

    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

    http://www.catb.org/~esr/faqs/smart-questions.html

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbynet
      wrote on last edited by
      #3

      please post example

      @void MainWindow::spShShow()
      {
      QWidget *wgt = new QWidget();
      wgt->resize(200,200);
      mdiArea->addSubWindow(wgt);
      wgt->show();
      }

      @

      dont work too

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Franzk
        wrote on last edited by
        #4

        Untested but most likely to work:
        @QWidget *w = new QWidget;
        QMdiSubWindow *sw = mdiArea->addSubWindow(w);
        sw->resize(200,200);
        sw->show();@

        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mbynet
          wrote on last edited by
          #5

          i use this example, dont work. sw - show max window.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #6

            This works as expected:

            @

            #include <QApplication>
            #include <QMainWindow>
            #include <QMdiArea>
            #include <QMdiSubWindow>
            #include <QTextEdit>

            int main(int argc, char **argv)
            {
            QApplication a(argc, argv);

            QMainWindow mw;
            QMdiArea *mdi = new QMdiArea(&mw);
            mw.setCentralWidget(mdi);
            
            QTextEdit *te = new QTextEdit;
            QMdiSubWindow *sw = mdi->addSubWindow(te);
            sw->resize(300,100);
            sw->show();
            
            mw.show();
            a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
            return a.exec&#40;&#41;;
            

            }
            @

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #7

              BTW: Are you sure you call the right function?MainWindow::spClientShow() always shows your new Window maximized!

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mbynet
                wrote on last edited by
                #8

                [quote author="Volker" date="1288698753"]This works as expected:

                @

                #include <QApplication>
                #include <QMainWindow>
                #include <QMdiArea>
                #include <QMdiSubWindow>
                #include <QTextEdit>

                int main(int argc, char **argv)
                {
                QApplication a(argc, argv);

                QMainWindow mw;
                QMdiArea *mdi = new QMdiArea(&mw);
                mw.setCentralWidget(mdi);
                
                QTextEdit *te = new QTextEdit;
                QMdiSubWindow *sw = mdi->addSubWindow(te);
                sw->resize(300,100);
                sw->show();
                
                mw.show();
                a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
                return a.exec&#40;&#41;;
                

                }
                @[/quote]

                question another!!!!

                @#include <QApplication>
                #include <QMainWindow>
                #include <QMdiArea>
                #include <QMdiSubWindow>
                #include <QTextEdit>

                int main(int argc, char **argv)
                {
                QApplication a(argc, argv);

                QMainWindow mw;
                QMdiArea *mdi = new QMdiArea(&mw&#41;;
                mw.setCentralWidget(mdi);
                
                QTextEdit *te = new QTextEdit;
                QMdiSubWindow *sw = mdi->addSubWindow(te);
                

                // sw->resize(300,100);
                sw->showMaximized();

                QTextEdit *ti = new QTextEdit;
                QMdiSubWindow *sb = mdi->addSubWindow(ti);
                sb->resize(300,100);
                sb->show();
                
                mw.show();
                a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
                return a.exec(&#41;;
                

                }
                @
                How Display QTextEdit *ti size(300,100)??? *ti Display Maximized. If push minimize 2 windows minimize and *ti take size 300,100

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

                  finish resault must out !http://img827.imageshack.us/img827/7070/11579515.jpg(2)!

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #10

                    You must call

                    @
                    mdi->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true);
                    @

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

                      [quote author="Volker" date="1288712567"]You must call

                      @
                      mdi->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true);
                      @[/quote]

                      big thanks, works

                      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
                      • Unsolved