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. How QWidget::geometry work? I'm really confuse.
Qt 6.11 is out! See what's new in the release blog

How QWidget::geometry work? I'm really confuse.

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 582 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.
  • A Offline
    A Offline
    Arrandale
    wrote on last edited by
    #1

    QMainWindow // base
    -->QWidget // central widget (myWidget)
    ---->QTextEdit // child of myWidget (myTextEdit)
    ------> QDialog // child of myTextEdit (myDialog)

    Now I want to move myDialog to center of myTextEdit by using QWidget::geometry
    but geometry of myTextEdit never return a current geometry.

    ex.
    myTextEdit has 400 x 200, when call geometry.center it's always return 200 x 100. What?
    I want current geometry not a current size. I try to myTextEdit.updateGeometry
    before calling myTextEdit.geometry.center but still does not work.
    How to properly update myTextEdit's geometry?

    (I'm not using the Designer, all layout and widgets create in constructor of QMainWindow)

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      Well everything is correct. When you call myTextEdit.geometry.center you got center coordinates inside myTextEdit. You can map coordinates and then use it "mapToGlobal":http://qt-project.org/doc/qt-4.8/qwidget.html#mapToGlobal

      1 Reply Last reply
      0

      • Login

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