Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QT getting the screen resolution without the extended monitor

Tags:

qt

QDesktopWidget desktop;

int desktopHeight=desktop.geometry().height();
int desktopWidth=desktop.geometry().width();
this->resize(desktopWidth,desktopHeight);

for example my main monitor resolution is 1024 x 768 and my extended monitor resolution is 800x600. the value i get from desktop height and width is the sum of the two monitor resolution. i only need to get the main monitor resolution. can somebody tell me how? thanks. I'm using qt 4.7.3

edit: I'm using dual screen, particularly in cashier ordering the main monitor is seen by the cashier and the extended are seen by the costumer.

like image 860
reggie Avatar asked Jul 27 '13 01:07

reggie


People also ask

How do I make native resolution full screen?

To keep a custom resolution in Full Screen mode:Go to your virtual machine's configuration > Options > Full Screen. Expand Advanced Settings menu, then select Keep ratio from the Scale to fit screen drop-down menu: Start your virtual machine in Full Screen mode. Restart Windows.

How do I screen size in Qt?

Qt includes a very simple method to get the size of the screen (width and height). Here it is: QSize size = qApp->screens()[0]->size(); Note that this function works perfectly in Android and iOS too.

Why is my monitor not showing full resolution?

If your monitor is having problems with resolution, it's probably your graphics card! If you're getting a display, but it isn't displaying properly, it's probably just a matter of updating your graphics card's driver. If you're not getting a display at all, find your monitor in these guides and see if there's a fix.


1 Answers

You pretty much had it, just give the screen ID of your main monitor to the geometry() call.

QDesktopWidget widget;
QRect mainScreenSize = widget.availableGeometry(widget.primaryScreen()); // or screenGeometry(), depending on your needs
like image 186
Chris Avatar answered Oct 10 '22 00:10

Chris