Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using Absolute Positioning of a QWidget inside a QMainWindow
Forum Updated to NodeBB v4.3 + New Features

Using Absolute Positioning of a QWidget inside a QMainWindow

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 4.0k Views 1 Watching
  • 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 Offline
    J Offline
    JasonKretzer
    wrote on 28 Jun 2013, 16:45 last edited by
    #1

    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
    0

    1/1

    28 Jun 2013, 16:45

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved