Hi all,
I am working on Qt4.6 on mac os, I am working on MultiDialog Application. All the windows are in the layout, When I click on the maximize button on the top of the mainwindow appaers to be maximized. When i move from MainWindow to the next Dialog I want if MainWiindow is maximised then nextDialog should also be maximized.For this I used
if(this->isMaximized())
{
nextDialog->showMaximized();
}
if(this->isMaximized())
{
nextDialog->showMaximized();
}
To copy to clipboard, switch view to plain text mode
It works perfectly fine. But When I click on nextDialog maximize button to restore it to its orginalGeometry, then it resizes it to the original width and height but not the position, I appears on the bottom right, for this I am trying to get the center position in the resize event of the dialog but still no use.
For this I used:
{
this
->move
(QApplication::desktop()->screen
()->rect
().
center()- this
->rect
().
center());
}
void nextDialog::resizeEvent(QResizeEvent * event)
{
this->move(QApplication::desktop()->screen()->rect().center()- this->rect().center());
}
To copy to clipboard, switch view to plain text mode
But It wont appear in the center
I also tried this but again fails:
{
int dW = d->width();
int dH = d->height();
int mw = this->width();
int mH = this->height();
int cw = dW/2-mw/2;
int ch = dH/2-mH/2;
move(cw,ch);
}
void nextDialog::resizeEvent(QResizeEvent * event)
{
QDesktopWidget *d = QApplication::desktop();
int dW = d->width();
int dH = d->height();
int mw = this->width();
int mH = this->height();
int cw = dW/2-mw/2;
int ch = dH/2-mH/2;
move(cw,ch);
}
To copy to clipboard, switch view to plain text mode
Pls Suggest what should i do.
Bookmarks