Qt - 2 QMainWindow glued - Size of Layout
- by user1773603
I have a main window that I center this way in main.cpp :
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow *qmain = new QMainWindow;
Ui_MainWindow ui;
ui.setupUi(qmain);
QRect r = qmain->geometry();
r.moveCenter(QApplication::desktop()->availableGeometry().center());
qmain->setGeometry(r);
qmain->show();
return app.exec();
}
In this "qmain" main window, I can create another QMainWindow and I try to make stick (or glue I don't know how to say) the two windows. Actually, I would like the right-top corner of the first one to be located at the left-top of the second one. For this, I use the following Ui_MainWindow's member function :
void Ui_MainWindow::generate_IC()
{
qmenu = new QMainWindow;
DiskMenu = new Ui_DiskGalMenu;
DiskMenu->setupUi(qmenu);
setInitialDiskMenuPosition(qmenu, this);
qmenu->show();
}
and the setInitialDiskMenuPosition :
void Ui_MainWindow::setInitialDiskMenuPosition(QMainWindow *MainWindow, Ui_MainWindow *parent)
{
QSize size = parent->widget->size();
QDesktopWidget* desktop = QApplication::desktop();
int width = desktop->width();
int height = desktop->height();
int mw = size.width();
int mh = size.height();
int right = (width/2) + (mw/2);
int top = (height/2) - (mh/2);
MainWindow->move(right, top);
}
But the problem is that I don't get exactly what I want since the centralwidget size "parent- widget-size()" only returns the size of the widget and not the whole "qmain" parent window. So I have a light shift because the borders of the "qmain" window are not taken in account like it is shown below :
If I could have access to the size of the whole parent window...
If anyone could help me