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. QDialog Location
QtWS25 Last Chance

QDialog Location

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

    Hi,

    I've tried to set the location of my QDialog Popup window to the bottom right of my desktop.
    @
    QDesktopWidget *desktop = new QDesktopWidget();
    int desk_width = desktop->width()-100;
    int desk_height = desktop->height() -100;

    this->move(desk_width,desk_height);
    @
    The problem is, it says my width = 5245
    and height = 1080

    I've connected 3 monitors to my pc.
    might this be the problem for the width?

    how do I solve this?

    Edit: use @ tags around code please; Andre

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      First of all, you should get your QDesktopWidget from QApplication instead of just creating an instance.

      You have setup your system to have one big desktop, so QDesktopWidget reports that (total) size. If you want to stick to the 'current' screen, you'll need to fiddle a bit with using the screen geometries also provided by QDesktopWidget. Find out what screen your your main window is on, then get the bottom right corner of that screen.

      Also note that you are moving your dialog off screen at the moment. You are now moving the top left corner of your window to the bottom right corner of the screen. Hence, the window will fall off. Substract the window height and width from the coordinates to move to instead.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sleicreider
        wrote on last edited by
        #3

        thank you for the answer,
        this worked for me:

        @ QDesktopWidget desktop_widget;
        QRect mainScreenSize = desktop_widget.availableGeometry(desktop_widget.primaryScreen());
        int mainScreenHeight = mainScreenSize.height();
        int mainScreenWidth = mainScreenSize.width();

        int dialogWidth = this->width();
        int dialogHeight = this->height();
        
        this->move(mainScreenWidth - dialogWidth, mainScreenHeight - dialogHeight);
        

        @

        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