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. Start program center screen on main monitor
QtWS25 Last Chance

Start program center screen on main monitor

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 8.0k 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.
  • G Offline
    G Offline
    glararan
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      KA51O
      wrote on last edited by
      #2

      have you tried this:
      @
      map_selection_menu->move(0,0);
      @

      This should move your widget to the center of the primary screen.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        glararan
        wrote on last edited by
        #3

        @map_selection_menu->move(0,0);@

        move to left top on main screen

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          then get your resolution and place your widget at width/2, height/2

          1 Reply Last reply
          0
          • K Offline
            K Offline
            KA51O
            wrote on last edited by
            #5

            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).

            1 Reply Last reply
            0
            • G Offline
              G Offline
              glararan
              wrote on last edited by
              #6

              It isnt main window just QWidget.And i say move( 0, 0 ) dont help

              1 Reply Last reply
              0
              • K Offline
                K Offline
                KA51O
                wrote on last edited by
                #7

                Does your widget have a parent ?

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  glararan
                  wrote on last edited by
                  #8

                  Nope

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    KA51O
                    wrote on last edited by
                    #9

                    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)
                    @

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      glararan
                      wrote on last edited by
                      #10

                      I cant call
                      @QSize screenSize = QApplication::desktop()->geometry().size();@

                      :(
                      No suitable convert from QDesktopWidget* to QSize

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        andre
                        wrote on last edited by
                        #11

                        This is not the method you are after. Read the section Screen Geometry in the [[doc:QDesktopWidget]] documentation.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved