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. Graphic glitch when changing layoutDirection
Forum Updated to NodeBB v4.3 + New Features

Graphic glitch when changing layoutDirection

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 146 Views 1 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.
  • I Offline
    I Offline
    idkfa
    wrote on last edited by
    #1

    I have a qml project for MacOS. There is a frameless window where I have a big rectangle (mainView) with main functions and a small rectangle (expandRect) on a side which is used to drag the window so it can stick to one side of the screen or another.
    I need the main rectangle always to stick to the screen side so I'm changing mainLayout.layoutDirection.

    import QtQuick
    import QtQuick.Controls
    import QtQuick.Layouts
    import QtQuick.Window
    
    ApplicationWindow {
       id: browserWindow
    
       enum Side {
           Left,
           Right
       }
    
       property int currentSide: Main.Side.Right
    
       width: 432
       height: screen.desktopAvailableHeight
       visible: true
       flags: Qt.Window | Qt.FramelessWindowHint
    
       color: "transparent"
    
       Component.onCompleted: {
           stickToRight()
       }
    
       RowLayout {
           id: mainLayout
           anchors.fill: parent
    
           Rectangle {
               id: expandRect
               Layout.preferredWidth: 40
               Layout.preferredHeight: width
               radius: 7
               y: (parent.height - height) * 0.25
    
               MouseArea {
                   anchors.fill: parent
    
                   DragHandler {
                       onActiveChanged: {
                           if (active && !browserWindow.minimized)
                               startSystemMove()
                           if (x > screen.desktopAvailableWidth / 2)
                               stickToRight()
                           else
                               stickToLeft()
                       }
                   }
               }
           }
    
           Rectangle {
               id: mainView
               Layout.fillWidth: true
               Layout.fillHeight: true
               radius: 7
           }
       }
    
       onCurrentSideChanged: {
           if (currentSide === Main.Side.Right) {
               console.log("Side changed to right")
               mainLayout.layoutDirection = Qt.LeftToRight
           }
           if (currentSide === Main.Side.Left) {
               console.log("Side changed to left")
               mainLayout.layoutDirection = Qt.RightToLeft
    
               browserWindow.width--
               browserWindow.width++
           }
           // to get rid of transparent main window frame on MacOS we need to update window like this
           // browserWindow.width--
           // browserWindow.width++
       }
    
       function stickToRight() {
           browserWindow.x = screen.desktopAvailableWidth - browserWindow.width
           browserWindow.y = 0
           currentSide = Main.Side.Right
       }
    
       function stickToLeft() {
           browserWindow.x = 0
           browserWindow.y = 0
           currentSide = Main.Side.Left
       }
    }
    

    When I move the window a few times, I get this strange frame border. I cannot even get what item is this. 30f86a1a-9e39-4478-a53a-70566d44e6a5-image.png
    Has someone even any tips on what can it be? If you set mainView.visible = false in "stick" functions you'll see that this is some kind of silhouettes of both rectangles. But what is it and how to get rid of them?
    Any help is appreciated.

    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