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. Qt::FramelessWindowHint make QT_DEVICE_PIXEL_RATIO error
Forum Updated to NodeBB v4.3 + New Features

Qt::FramelessWindowHint make QT_DEVICE_PIXEL_RATIO error

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 1.9k Views 2 Watching
  • 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.
  • RobinR Offline
    RobinR Offline
    Robin
    wrote on last edited by
    #1

    When I set window flags is Qt::FramelessWindowHint and set QT_DEVICE_PIXEL_RATIO=2, my application really scaled bigger,but have some area don't click.
    If I remove window flags, It's become normal.

    Can I fix it?
    How fix it?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What OS/Qt version are you using ?

      What isn't clickable ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      RobinR 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        What OS/Qt version are you using ?

        What isn't clickable ?

        RobinR Offline
        RobinR Offline
        Robin
        wrote on last edited by
        #3

        @SGaist I am using win10 and Qt5.6.0.
        Isn't clickable is part of application's window don't get focus when mouse move to there.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you be more precise ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          RobinR 3 Replies Last reply
          0
          • SGaistS SGaist

            Can you be more precise ?

            RobinR Offline
            RobinR Offline
            Robin
            wrote on last edited by Robin
            #5

            @SGaist Sorry,It's my error,I overwrite QMainWindow's nativeEvent function,but I don't know

            int xPos = GET_X_LPARAM(message->lParam) - this->frameGeometry().x();
            

            the xPos is depend on QT_DEVICE_PIXEL_RATIO。
            e.g
            QT_DEVICE_PIXEL_RATIO=1,xPos = 100.
            QT_DEVICE_PIXEL_RATIO=2,xPos = 200.

            but this->width() don't depends on QT_DEVICE_PIXEL_RATIO。so my code make a error.

            bool RCMainWindow::winEvent(MSG *message, long *result)
            {
            
                switch (message->message)
                {
                case WM_NCHITTEST:
                    int xPos = GET_X_LPARAM(message->lParam) - this->frameGeometry().x();
                    int yPos = GET_Y_LPARAM(message->lParam) - this->frameGeometry().y();
                    if (this->childAt(xPos, yPos) == 0)
                    {
                        *result = HTCAPTION;
                    }
                    else {
                        return false;
                    }
                    if (xPos >=0 && xPos < 5)
                        *result = HTLEFT;
                    if (xPos >(this->width() - 5) && xPos < this->width() + 5)
                        *result = HTRIGHT;
                    if (yPos >= 0 && yPos < 5)
                        *result = HTTOP;
                    if (yPos >(this->height() - 5) && yPos < (this->height() + 5))
                        *result = HTBOTTOM;
                    if (xPos >= 0 && xPos < 5 && yPos >= 0 && yPos < 5)
                        *result = HTTOPLEFT;
                    if (xPos >(this->width() - 5) && xPos < (this->width() + 5) && yPos >= 0 && yPos < 5)
                        *result = HTTOPRIGHT;
                    if (xPos >= 0 && xPos < 5 && yPos >(this->height() - 5) && yPos < (this->height() + 5))
                        *result = HTBOTTOMLEFT;
                    if (xPos >(this->width() - 5) && xPos < (this->width() + 5) && yPos >(this->height() - 5) && yPos < (this->height() + 5))
                        *result = HTBOTTOMRIGHT;
            
                    return true;
            
                }
            
                return false;
            }
            

            I need to fix it 。

            bool RCMainWindow::winEvent(MSG *message, long *result)
            {
            
                switch (message->message)
                {
                case WM_NCHITTEST:
                    int xPos = GET_X_LPARAM(message->lParam) - this->frameGeometry().x();
                    int yPos = GET_Y_LPARAM(message->lParam) - this->frameGeometry().y();
                    int ratio = g_pApp->devicePixelRatio();
                    if(ratio > 1) {
                        xPos = xPos / ratio;
                        yPos = yPos / ratio;
                    }
                    if (this->childAt(xPos, yPos) == 0)
                    {
                        *result = HTCAPTION;
                    }
                    else {
                        return false;
                    }
                    if (xPos >=0 && xPos < 5)
                        *result = HTLEFT;
                    if (xPos >(this->width() - 5) && xPos < this->width() + 5)
                        *result = HTRIGHT;
                    if (yPos >= 0 && yPos < 5)
                        *result = HTTOP;
                    if (yPos >(this->height() - 5) && yPos < (this->height() + 5))
                        *result = HTBOTTOM;
                    if (xPos >= 0 && xPos < 5 && yPos >= 0 && yPos < 5)
                        *result = HTTOPLEFT;
                    if (xPos >(this->width() - 5) && xPos < (this->width() + 5) && yPos >= 0 && yPos < 5)
                        *result = HTTOPRIGHT;
                    if (xPos >= 0 && xPos < 5 && yPos >(this->height() - 5) && yPos < (this->height() + 5))
                        *result = HTBOTTOMLEFT;
                    if (xPos >(this->width() - 5) && xPos < (this->width() + 5) && yPos >(this->height() - 5) && yPos < (this->height() + 5))
                        *result = HTBOTTOMRIGHT;
            
                    return true;
            
                }
            
                return false;
            }
            
            1 Reply Last reply
            0
            • SGaistS SGaist

              Can you be more precise ?

              RobinR Offline
              RobinR Offline
              Robin
              wrote on last edited by
              #6

              @SGaist Thank you! I solved my problem.
              How change this topic's status ?

              1 Reply Last reply
              0
              • SGaistS SGaist

                Can you be more precise ?

                RobinR Offline
                RobinR Offline
                Robin
                wrote on last edited by
                #7

                @SGaist Now I had other problem.
                When I set QT_DEVICE_PIXEL_RATIO = 2 and windowflag = Qt::FramelessWindowHint.
                then QMainWindow's show max error that don't full all screen.

                normal.jpg
                max.jpg
                code

                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