[Qt-interest] run on the second screen

Andre Somers andre at familiesomers.nl
Wed Oct 28 15:07:55 CET 2009


SALOMEHER at terra.es wrote:
> Hi,
> I have two screens, do the following:
>     qApp->desktop()->numScreens()        return 2.
> But what I want is that my application run on the second monitor. How 
> do I do this?
> I tried
>      Qwidget *w2 = new Qwidget (qApp->desktop()->screen(1))   but does 
> not work.
> Any ideas?

Top widgets are created with a 0 parent, but they do have a position. 
Simply position the window into the rect occupied by the second screen. 
You can get that rect using QDesktopWidget::screenGeometry(1) or 
::availableGeometry(1) (1 because we start counting at 0, of course). 
Use that rect to position your window properly.

André






More information about the Qt-interest-old mailing list