Important: Please read the Qt Code of Conduct -

Using Absolute Positioning of a QWidget inside a QMainWindow

  • This post has been revised. See the new
    "**Revised Question Here **":

    Very new to QT and ask to be pointed in the right direction. Thanks!

    I have a QMainWindow that is roughly 1280x1024.
    QScreen screen = qApp->screens().at(0);
    display = new QMainWindow();

    This works as intended, I get a nice window that is the appropriate size. Life is Good.

    After this, I try to add a QWidget to the QMainWindow.
    QWidget *c = new QWidget(display);

    I then try to set the Geometry(top left coordinate, height, width) of the QWidget.
    c->setGeometry(100, 100, 200, 200);

    This did not work as intended. It set the size to 200x200, which is great. However, it put it in the top left corner of the window.

    So, I tried this, with the same result.


    I added combinations of the following to no avail.

    I would appreciate any help. Thanks!

Log in to reply