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 to get the geometry of the screen on which the app is started
Forum Updated to NodeBB v4.3 + New Features

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 40 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 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 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 Extensions
      • Unsolved