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. Help on QDialog Position
Forum Updated to NodeBB v4.3 + New Features

Help on QDialog Position

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 7.2k 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.
  • M Offline
    M Offline
    M_31
    wrote on last edited by
    #1

    when i press the Parent Window's PushButton
    i want to show the child dialog window exactly below my pushButton of the Parent Dialog Window,
    May i know how to set the position of the Child dialog to fit below the pushButton , even when the Parent dialog is Maximed or Restored.
    @
    Parent Dialog

    pushBtn
    ----------

    @

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      What about getting PushButton's @pos()@ value (QPoint), then setting the new window's position appropriately, like @QWidget::move (QPoint.x, QPoint.y);@ ??

      --

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #3

        If the new window is a top level window, you have to use global coordinates.
        that means:

        @
        CMyDialog dlg;
        dlg.show();

        QPoint ptGlobal = ui->pushButton->mapToGlobal(QPoint(0, ui->pushButton->height()));
        QPoint ptLeftTop = mapToGlobal(QPoint(0,0));
        QPoint ptFrame = frameGeometry().topLeft();
        ptGlobal += (ptLeftTop - ptFrame); // add border size
        dlg.setGeometry(QRect(ptGlobal, dlg.size()));
        
        dlg.exec();
        

        @

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        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