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. How Can I understand where mainWindow is?
QtWS25 Last Chance

How Can I understand where mainWindow is?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 616 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on 15 Apr 2019, 15:26 last edited by
    #1

    there is a way to understand where is the MainWindow?
    I used mainWindow::pos and I noticed that when it's in the first screen MainWindow::pos().width()= -1, but I don't know if it's always

    ? 1 Reply Last reply 15 Apr 2019, 15:35
    0
    • ? A Former User
      15 Apr 2019, 15:26

      there is a way to understand where is the MainWindow?
      I used mainWindow::pos and I noticed that when it's in the first screen MainWindow::pos().width()= -1, but I don't know if it's always

      ? Offline
      ? Offline
      A Former User
      wrote on 15 Apr 2019, 15:35 last edited by
      #2

      @vale88 sorry, I explained badly, I saw that when mainWindow is in the first screen this->pos().x()=-1, but I don't know if it's right for all the screens

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 15 Apr 2019, 15:56 last edited by
        #3

        Hi
        Why do you want to know ?
        you can always check the screen its on
        QScreen *screen = widget/mainwin->window()->windowHandle()->screen();
        the x() should change depending on screen but i never checked it.

        ? 1 Reply Last reply 15 Apr 2019, 18:59
        1
        • M mrjj
          15 Apr 2019, 15:56

          Hi
          Why do you want to know ?
          you can always check the screen its on
          QScreen *screen = widget/mainwin->window()->windowHandle()->screen();
          the x() should change depending on screen but i never checked it.

          ? Offline
          ? Offline
          A Former User
          wrote on 15 Apr 2019, 18:59 last edited by
          #4

          @mrjj ok tomorrow I try, so in this way I obtain 0 or 1 and I understand which is the screen..

          M 1 Reply Last reply 15 Apr 2019, 20:50
          0
          • ? A Former User
            15 Apr 2019, 18:59

            @mrjj ok tomorrow I try, so in this way I obtain 0 or 1 and I understand which is the screen..

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 15 Apr 2019, 20:50 last edited by
            #5

            @vale88
            well you get the actual screen object.
            https://doc.qt.io/qt-5/qscreen.html
            It can tell you size and tons other stuff about the screen.

            ? 1 Reply Last reply 16 Apr 2019, 10:35
            1
            • M mrjj
              15 Apr 2019, 20:50

              @vale88
              well you get the actual screen object.
              https://doc.qt.io/qt-5/qscreen.html
              It can tell you size and tons other stuff about the screen.

              ? Offline
              ? Offline
              A Former User
              wrote on 16 Apr 2019, 10:35 last edited by
              #6

              @mrjj if I write this I obtain the name of the screen , but I need only to know if it's the first screen or the secondary

              M 1 Reply Last reply 16 Apr 2019, 10:46
              0
              • ? A Former User
                16 Apr 2019, 10:35

                @mrjj if I write this I obtain the name of the screen , but I need only to know if it's the first screen or the secondary

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 16 Apr 2019, 10:46 last edited by mrjj
                #7

                @vale88
                Hi
                try
                (do not call from constructor as windowHandle() is not set there yet)

                QScreen *screen = this->window()->windowHandle()->screen();
                    if ( QGuiApplication::primaryScreen() == screen )
                        qDebug() << "yes!";
                
                1 Reply Last reply
                2

                6/7

                16 Apr 2019, 10:35

                • Login

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