Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Window span accross two screens
Forum Updated to NodeBB v4.3 + New Features

QML Window span accross two screens

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 351 Views 3 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.
  • T Offline
    T Offline
    theunsheydenrych
    wrote on last edited by theunsheydenrych
    #1

    HI
    I have a QML application and I would like to have the application window span over two screens. The screen sizes is 1980x1080.
    I am using Kubuntu 20.04 and Qt6.2.3
    When running the application it just "snaps" to the top of the left screen.
    I console logged the value of the window width out in Component.onCompleted the output looks like this

    QML debugging is enabled. Only use this in a safe environment.
    qml: Window Width 3960 // Width in Component.onCompleted
    qml: onWidthChanged: 1920
    

    Its is created with the correct size, then the size is just changed to the size of one screen (1920)

    This is the code

    import QtQuick
    import QtQuick.Controls 2.12
    
    Window {
        id: mainScreen
        y: 0
        x: 0
        width: 3840
        height: 1080
        visible: true
        onWidthChanged: {
            console.log("onWidthChanged: " + width)
        }
        title: qsTr("Hello World")
        Component.onCompleted: {
            console.log("Window Width", width)
        }
    }
    

    What do I have to change or add so that it keeps the width?

    MarkkyboyM 1 Reply Last reply
    0
    • L Offline
      L Offline
      lemons
      wrote on last edited by lemons
      #2

      the easiest way is to set the minimumWidth of the window, as then the window manager does not take over the window sizing:

      Window {
          id: window
          visible: true
          minimumWidth: Screen.desktopAvailableWidth
          height: Screen.desktopAvailableHeight
      }
      

      alternatively you could simply bypass the window manager completely. this way you can span the application across all screens the system has access to. note you should have a close button present when testing. It totally depends on the use case if this is a suitable solution. for applications, that just display information in fullscreen, this is a simple solution.

      Window {
          id: window
          visible: true
          width: Screen.desktopAvailableWidth
          height: Screen.desktopAvailableHeight
          flags: Qt.BypassWindowManagerHint
      
          Button {
              text: "CLOSE"
              anchors.top: parent.top
              anchors.right: parent.right
              anchors.margins: 10
              onClicked: Qt.quit()
          }
      }
      
      T 1 Reply Last reply
      2
      • T theunsheydenrych

        HI
        I have a QML application and I would like to have the application window span over two screens. The screen sizes is 1980x1080.
        I am using Kubuntu 20.04 and Qt6.2.3
        When running the application it just "snaps" to the top of the left screen.
        I console logged the value of the window width out in Component.onCompleted the output looks like this

        QML debugging is enabled. Only use this in a safe environment.
        qml: Window Width 3960 // Width in Component.onCompleted
        qml: onWidthChanged: 1920
        

        Its is created with the correct size, then the size is just changed to the size of one screen (1920)

        This is the code

        import QtQuick
        import QtQuick.Controls 2.12
        
        Window {
            id: mainScreen
            y: 0
            x: 0
            width: 3840
            height: 1080
            visible: true
            onWidthChanged: {
                console.log("onWidthChanged: " + width)
            }
            title: qsTr("Hello World")
            Component.onCompleted: {
                console.log("Window Width", width)
            }
        }
        

        What do I have to change or add so that it keeps the width?

        MarkkyboyM Offline
        MarkkyboyM Offline
        Markkyboy
        wrote on last edited by
        #3

        @theunsheydenrych - you are giving different sizes for your monitors, are you sure about 1980 wide?, not 1920? (as 1920 x 2 = 3840), where as 1980 x 2 = 3960. Yet in your code, I see 3840 as width.

        I have an app that I wanted to display at the bottom of my second monitor, here is the code (it might help you with positioning);

        Window {
            id: main
            visible: true
        
            width: 1920 // <--- width of my application's window
            height: 100 // <--- height of my application's window
            x: 1920     // <--- where my app sits horizontally in second monitor
            y: 980      // <--- where my app sits vertically in second monitor
        
            color: "#00000000"
            flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
        

        Don't just sit there standing around, pick up a shovel and sweep up!

        I live by the sea, not in it.

        1 Reply Last reply
        0
        • L lemons

          the easiest way is to set the minimumWidth of the window, as then the window manager does not take over the window sizing:

          Window {
              id: window
              visible: true
              minimumWidth: Screen.desktopAvailableWidth
              height: Screen.desktopAvailableHeight
          }
          

          alternatively you could simply bypass the window manager completely. this way you can span the application across all screens the system has access to. note you should have a close button present when testing. It totally depends on the use case if this is a suitable solution. for applications, that just display information in fullscreen, this is a simple solution.

          Window {
              id: window
              visible: true
              width: Screen.desktopAvailableWidth
              height: Screen.desktopAvailableHeight
              flags: Qt.BypassWindowManagerHint
          
              Button {
                  text: "CLOSE"
                  anchors.top: parent.top
                  anchors.right: parent.right
                  anchors.margins: 10
                  onClicked: Qt.quit()
              }
          }
          
          T Offline
          T Offline
          theunsheydenrych
          wrote on last edited by theunsheydenrych
          #4

          @lemons Thank you for response.

          Window {
          id: window
          visible: true
          minimumWidth: Screen.desktopAvailableWidth
          height: Screen.desktopAvailableHeight
          }

          Works for me.

          Only issue I have now, is that "Other" things use screen real estate, like in Ubuntu, the Dock on the side, you have to set it not to use the full height of the screen, only then the window manager, will place the QML Window at 0,0. Also the top bar, take some screen real estate, so the Screen.desktopAvailableHeight does not take that in account, and you have to tweak the window height to fit better.

          But thank you, you definitely put me on the right track.

          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