[SOLVED] How to display a window on a secondary display in PyQT?

Issue

I am developing an application; which will run on a system with 2 displays. I want my PyQt app to be able to automatically route a particular window to the second screen.

How can this be done in Qt? (either in Python or C++)

Solution

Use QDesktopWidget to access to screen information on multi-head systems.

Here is pseudo code to make a widget cover first screen.

QDesktopWidget *pDesktop = QApplication::desktop ();

//Get 1st screen's geometry
QRect RectScreen0 = pDesktop->screenGeometry (0);

//Move the widget to first screen without changing its geometry
my_Widget->move (RectScreen0.left(),RectScreen0.top());

my_pWidget->resize (RectScreen0.width(),RectScreen0.height());

my_Widget->showMaximized();

Answered By – O.C.

Answer Checked By – Cary Denson (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *