Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get the geometry of the screen on which the app is started
Qt 6.12 LTS is out! See what's new in the release blog

How to get the geometry of the screen on which the app is started

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 454 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.
  • R Offline
    R Offline
    rstamm.dev
    wrote on last edited by
    #1

    Hi,

    #include "mainwindow.h"
    
    #include <QDebug>
    #include <QScreen>
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
    {
    
        qDebug() << screen()->availableGeometry();
    
        resize(screen()->availableGeometry().width() * 2/3, screen()->availableGeometry().height() * 2/3);
        move((screen()->availableGeometry().width() - width()) / 2, (screen()->availableGeometry().height() - height()) / 2);
    
    }
    
    MainWindow::~MainWindow() {}
    

    When I start the app on the external monitor, I get the geometry of the notebook display.
    How do I get the geometry of the screen on which the app is started?

    Setup is Arch, Wayland, and KDE on a notebook(FullHD, secondary) with an external monitor(QHD, primary display)

    Thanks

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Is QGuiApplication::primaryScreen() useful?

      1 Reply Last reply
      1

      • Login

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