PDA

View Full Version : Set up geometry of vertically arranged windows



abshaev
19th August 2017, 18:52
Hello everybody!

How to correctly set up geometry of two daughter windows (inherited from QDialog class) below main window (inherited from QMainWindow).
The problem is that I cannot place all 3 windows exactly close to each other one by one.
What I have is overlapping or some distance between borders of windows, etc.


MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);

QRect screenGeometry = QApplication::desktop()->screenGeometry();
int MainWinWidth = 240;
int MainWinHeight = 120;
this->setWindowTitle("Main Window");
this->setFixedSize(MainWinWidth, MainWinHeight);
this->move(screenGeometry.width() - this->width(), screenGeometry.top());
this->show();

QRect MainWinRect = this->geometry();
int VerWinHeight = 300;
fVerSec = new VerticalSection(this);
fVerSec->setWindowTitle(tr("Vertical Section"));
fVerSec->resize(this->width(), VerWinHeight);
fVerSec->move(this->geometry().left(), this->geometry().top() + this->height() - 1);
fVerSec->show();

flist_vsf = new list_vsf(this);
flist_vsf->setWindowTitle(tr("Scans"));
flist_vsf->resize(this->width(), screenGeometry.height() - fVerSec->geometry().top() - fVerSec->height());
flist_vsf->move(this->geometry().left(), fVerSec->geometry().top() + fVerSec->geometry().height());
flist_vsf->show();
}

high_flyer
19th August 2017, 23:17
Try using the the dimensions (width/height) from QWindow::frameGeometry() as this geometry includes the windows frame.
You might need also QWindow::frameMargins().

Hope this helps.

abshaev
20th August 2017, 08:57
I cannot find frameMargins propertie in a QDialog

high_flyer
20th August 2017, 22:37
You need to get the QWindows objects from your application with QGuiApplication::allWindows(), or QGuiApplication::topLevelWindows().
Each Qt application has a qApp pointer to the QGuiApplication singleton.
You can access it anywhere in your application.