PDA

View Full Version : My first qt question: how can I convert a MDIsubwindow to popup windows back and forc



alxwang
1st February 2009, 00:44
Hi all , I am new here.
What I want to do is:
I have a MDI app in page mode. I want user can select a page and change that window into popup window(parent as desktop) so he can drag it out side of MDI app window.
Also I want that popup window can be converted back to one page of MDI window.

Does anyone know how can I do this?
Thanks.



I am using QT 4.4.3

caduel
1st February 2009, 10:00
see QMdiArea::removeSubWindow(), QMdiSubWindow::widget() etc

alxwang
1st February 2009, 22:31
Tks.
It is kind of works.
I remove the QMdiSubWindow to another mdiarea in another qmainwindow.
Then before the new window close I addSubWindow it back to mdiarea again.
It works fine in Window but in MAC, it never come back. New tab added but when I click that tab nothing(just gray area) displayed. If I switch to another page this page's header just be gray out.

Any hint?
THanks again.

wysota
2nd February 2009, 00:12
Can we see the code?

alxwang
2nd February 2009, 03:10
Sure.
When I need to move the MDIsubWindow to desktop:


QMdiArea *area = new QMdiArea();
QMdiSubWindow *subWin = this->mdiArea->activeSubWindow();
// I did try to remove this subwin from mdiArea first but not difference
area->addSubWindow(subWin);
XSubWindow *win = new XSubWindow();
win->setMdiArea(area);
win->show();
connect(win, SIGNAL(returnSubWindow(QMdiSubWindow*)), this, SLOT(getReturnedSubWindow(QMdiSubWindow*)));



XSubWindow is just a QMainWindow with
closeEvent like


void XSubWindow::closeEvent(QCloseEvent *event)
{
emit returnSubWindow(this->mdiArea->activeSubWindow());
event->accept();

}


to handle the returnSubWindow in main MDI window:


void MainWindow::getReturnedSubWindow(QMdiSubWindow *rwin)
{
this->mdiArea->addSubWindow(rwin);

}


The content of MDIsubWindow is ether a WEBkit window:


XWebWidget *child = new XWebWidget;
child->setWindowTitle("Demo");
mdiArea->addSubWindow(child);


or
QGraphicsScene only contains a picture.


QGraphicsScene scene;
scene.setSceneRect(-300, -300, 600, 600);
scene.setItemIndexMethod(QGraphicsScene::NoIndex);

QGraphicsView *view = new QGraphicsView;
view->setWindowTitle("Demo Bid Page");
view->setRenderHint(QPainter::Antialiasing);
view->setBackgroundBrush(QPixmap(":/images/demo.jpg"));

mdiArea->addSubWindow(view);

alxwang
3rd February 2009, 19:55
No one knows?

caduel
4th February 2009, 07:46
without looking at your code in too much detail:
probably your window does get closed after adding it to the other QMDiArea.
Try ignoring (or if that does not work: filtering) the close event.

HTH