Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Using Absolute Positioning of a QWidget inside a QMainWindow

    General and Desktop
    1
    1
    3800
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      JasonKretzer last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • First post
        Last post