Results 1 to 2 of 2

Thread: QML Window unable to set geometry when moving across screens

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default QML Window unable to set geometry when moving across screens

    Hi all,

    I'm having some problem with my application where when I drag it from a HD monitor to a 4k monitor with 125% dpi scaling my application print error like:
    Qt Code:
    1. QWindowsWindow::setGeometry: Unable to set geometry 640x480+3210+774 on QQuickApplicationWindow_QML_0/''. Resulting geometry: 1280x960+3210+774 (frame: 0, 0, 0, 0, custom margin: 0, 0, 0, 0, minimum size: 0x0, maximum size: 16777215x16777215).
    To copy to clipboard, switch view to plain text mode 

    Sometimes the window will resize to very large or very small sizes just by dragging it from one monitor to the other (OS Windows 10).

    EDIT: I forgot to say but I have on my application:
    Qt Code:
    1. QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    To copy to clipboard, switch view to plain text mode 
    Dpi scaling works fine until suddenly the problem happens after moving the window a couple of times back and forth.

    Please see below a snippet of my code:

    Qt Code:
    1. import QtQuick 2.10
    2. import QtQuick.Controls 2.3
    3. import QtQuick.Layouts 1.3
    4. import QtQuick.Controls.Styles 1.4
    5. import QtWebEngine 1.8
    6.  
    7. ApplicationWindow {
    8. id: mainWindow
    9. visible: true
    10. width: 640
    11. height: 480
    12.  
    13. flags: Qt.Window | Qt.FramelessWindowHint // Frameless window
    14.  
    15. StackView {
    16. id: stack
    17. anchors.fill: parent
    18.  
    19. Rectangle {
    20. id: menubar
    21. width: parent.width
    22. height: 20
    23. color: "black"
    24.  
    25. RowLayout {
    26. anchors.fill: parent
    27.  
    28. Item { Layout.fillWidth: true }
    29. Button {
    30. id: minimize_btn
    31. Layout.preferredWidth: 20
    32. Layout.preferredHeight: 20
    33.  
    34. background:
    35. Rectangle
    36. {
    37. antialiasing: true
    38. color: "transparent"
    39. }
    40.  
    41. Image {
    42. anchors.leftMargin: 3
    43. anchors.rightMargin: 3
    44. anchors.topMargin: 8
    45. anchors.bottomMargin: 8
    46. anchors.fill: parent
    47. source: "qrc:/titleBarWin/minimize_button.png"
    48. }
    49. }
    50. Button {
    51. id: maximize_btn
    52. Layout.preferredWidth: 20
    53. Layout.preferredHeight: 20
    54.  
    55. background:
    56. Rectangle
    57. {
    58. antialiasing: true
    59. color: "transparent"
    60. }
    61.  
    62. Image {
    63. anchors.leftMargin: 5
    64. anchors.rightMargin: 5
    65. anchors.topMargin: 5
    66. anchors.bottomMargin: 5
    67. anchors.fill: parent
    68. source: "qrc:/titleBarWin/maximize_button.png"
    69. }
    70. }
    71. Button {
    72. id: close_btn
    73. Layout.preferredWidth: 20
    74. Layout.preferredHeight: 20
    75.  
    76. background:
    77. Rectangle
    78. {
    79. antialiasing: true
    80. color: "transparent"
    81. }
    82.  
    83. Image {
    84. anchors.leftMargin: 5
    85. anchors.rightMargin: 5
    86. anchors.topMargin: 5
    87. anchors.bottomMargin: 5
    88. anchors.fill: parent
    89. source: "qrc:/titleBarWin/close_button.png"
    90. }
    91. }
    92. }
    93. }
    94.  
    95. WebEngineView {
    96. id: webEngine
    97. anchors {
    98. top: menubar.bottom
    99. left: menubar.left
    100. right: menubar.right
    101. }
    102.  
    103. height: parent.height
    104.  
    105. url: "https://www.qt.io"
    106. }
    107. }
    108. // define mouse areas to resize/move window
    109. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by mont3z; 4th February 2019 at 23:12.

Similar Threads

  1. Replies: 1
    Last Post: 5th July 2017, 13:05
  2. Replies: 3
    Last Post: 14th October 2015, 18:25
  3. Moving window
    By Kangs in forum Qwt
    Replies: 3
    Last Post: 13th September 2011, 19:12
  4. Storing window geometry inside XML file.
    By GuS in forum Qt Programming
    Replies: 4
    Last Post: 17th July 2008, 13:42
  5. Replies: 2
    Last Post: 23rd April 2006, 01:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.