Results 1 to 4 of 4

Thread: Set up geometry of vertically arranged windows

  1. #1
    Join Date
    Feb 2016
    Posts
    12
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Set up geometry of vertically arranged windows

    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();
    }

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Set up geometry of vertically arranged windows

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Feb 2016
    Posts
    12
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Set up geometry of vertically arranged windows

    I cannot find frameMargins propertie in a QDialog

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Set up geometry of vertically arranged windows

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Vertically flipped QImage.
    By xtrememoo in forum Qt Programming
    Replies: 4
    Last Post: 11th August 2014, 02:36
  2. QScrollArea that only scrolls vertically
    By stephelton in forum Qt Programming
    Replies: 1
    Last Post: 13th January 2013, 11:48
  3. Retrieve other windows geometry
    By Talei in forum Newbie
    Replies: 1
    Last Post: 25th January 2011, 23:27
  4. Thumbnails arranged in a grid
    By mboeni in forum Newbie
    Replies: 5
    Last Post: 2nd November 2010, 20:28
  5. Replies: 0
    Last Post: 3rd July 2010, 09:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.