[Solved] Display QMainwWindow and QMdiArea
-
MdiArea setCentralWidget MainWindow . To mdiarea add subwindow ClientWindow. In ClientWindow click pushbutton after addsubwindow Qwidget. ClientWindow & QWidegt showmaximized. How display QWidget size(200,200)? Resize dont work
@#include <QtGui>
#include "mainwindow.h"MainWindow::MainWindow()
{createActions(); createMenus(); mdiArea = new QMdiArea();
// mdiArea->setViewMode(QMdiArea::TabbedView);
setCentralWidget(mdiArea);
setWindowTitle(trUtf8("Quality Jobs Projects"));
showMaximized();}
MainWindow::~MainWindow()
{}
void MainWindow::createActions()
{
spClient = new QAction(trUtf8("Клиенты"),this);
connect(spClient,SIGNAL(triggered()),this,SLOT(spClientShow()));}
void MainWindow::createMenus()
{
spMenu = menuBar()->addMenu(trUtf8("Справочники"));
spMenu->addAction(spClient);}
void MainWindow::spClientShow()
{
clWindow = new ClientWindow;
mdiArea->addSubWindow(clWindow);
connect(clWindow->getAddAction(),SIGNAL(triggered()),this,SLOT(spShShow()));
clWindow->setWindowTitle(trUtf8("Клиенты"));
clWindow->showMaximized();}
void MainWindow::spShShow()
{
QWidget *wgt = new QWidget();
mdiArea->addSubWindow(wgt);
wgt->show();
}@
Picture:
!http://img408.imageshack.us/img408/7256/36399747.gif(1)! -
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.
-
please post example
@void MainWindow::spShShow()
{
QWidget *wgt = new QWidget();
wgt->resize(200,200);
mdiArea->addSubWindow(wgt);
wgt->show();
}@
dont work too
-
Untested but most likely to work:
@QWidget *w = new QWidget;
QMdiSubWindow *sw = mdiArea->addSubWindow(w);
sw->resize(200,200);
sw->show();@ -
i use this example, dont work. sw - show max window.
-
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();
}
@ -
BTW: Are you sure you call the right function?MainWindow::spClientShow() always shows your new Window maximized!
-
[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();
}
@[/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); 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();
}
@
How Display QTextEdit *ti size(300,100)??? *ti Display Maximized. If push minimize 2 windows minimize and *ti take size 300,100 -
finish resault must out !http://img827.imageshack.us/img827/7070/11579515.jpg(2)!
-
You must call
@
mdi->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true);
@ -
[quote author="Volker" date="1288712567"]You must call
@
mdi->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true);
@[/quote]big thanks, works