Start program center screen on main monitor
-
Hi, i have in computer two monitors... and when i use this code:
@map_selection_menu->move(QApplication::desktop()->availableGeometry(0).width() + 1, map_selection_menu->y());@
It start between two monitors... and i need to start it in center or main monitor...better will be when program detect all monitors and after calculate to main...
I have for screens connected:
@if (QApplication::desktop()->screenCount() > 1)
{
QRect geom = QApplication::desktop()->screenGeometry(0);
}@But now i dont know what with "if" ... how i can continue?
-
then get your resolution and place your widget at width/2, height/2
-
have you tried it? I did it with move(0,0) and it was in center of the screen. See "this code":http://developer.qt.nokia.com/forums/viewthread/10075/.
Is your widget the main window or a child widget? Because child widgets are always at center of parent widget per default. And I think main window is at center of primary screen per default.
Does QWidget::move(int x, int y) move to position x,y or does it move to a position that is x further left or right and y further up or down ? The later would explain why move(0,0) put my splashscreen to center (because it was allready at center and was moved 0 further right and 0 further up).
-
try
@
QSize screenSize = QApplication::desktop()->geometry().size();
int primaryScreenWidth = screenSize.width();
int primaryScreeHeight= screenSize.height();
int widgetWidth = yourWidget.width();
int widgetHeight= yourWidget.height();
yourWidget->move(primaryScreenWidth/2 - widgetWidth/2, primaryScreeHeight/2 - widgetHeight/2)
@