Using Absolute Positioning of a QWidget inside a QMainWindow



  • This post has been revised. See the new
    "**Revised Question Here **":http://qt-project.org/forums/viewthread/29465/

    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);
    QMainWindow
    display = new QMainWindow();
    display->setGeometry(screen->geometry());
    display->setWindowTitle(screen->name());
    display->show();
    @

    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.

    @
    c->resize(200,200);
    c->move(100,100);
    @

    I added combinations of the following to no avail.
    @
    display->repaint();
    //and
    c->repaint();
    @

    I would appreciate any help. Thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.