0

I'm running a pyqt5 application on an ubuntu and when the app is in full screen mode, I get this behavior of the dock and title bar popping over the application when a dialog box is clicked. When the dialog box is closed, everything goes back to normal. This issue doesn't happen on my intel but happens on ARM64. My system is the Jetson AGX Xavier 32GB. I've posted a sample code below that reproduces the issue.

I saw another post that suggested in setting the window flag Qt.X11BypassWindowManagerHint or Qt.BypassWindowManagerHint, even though it came with some issues but that didn't work either.

Any help would be greatly appriciated.

from PyQt5.QtWidgets import QComboBox, QVBoxLayout, QWidget, QHBoxLayout, QApplication, QFileDialog, QPushButton, QMainWindow
from PyQt5.QtCore import Qt
import sys
import pyautogui


class TestCode(QMainWindow):

    def __init__(self):
        super(TestCode, self).__init__()

        self.OpenDialog = QPushButton()
        self.OpenDialog.setText("OPEN D BOX")
        self.OpenDialog.clicked.connect(self.openDBox)

        self.closeWindow = QPushButton()
        self.closeWindow.setText("CLOSE")
        self.closeWindow.clicked.connect(self.close)

        colors = ["Yellow", "Magenta", "Black", "White",
                       "Green", "Blue", "Cyan", "Red"]
        self.drop_down = QComboBox()
        for color in colors:
            self.drop_down.addItem(color)

        self.buttonLayout = QVBoxLayout()
        self.buttonLayout.addWidget(self.OpenDialog)
        self.buttonLayout.addWidget(self.drop_down)
        self.buttonLayout.addWidget(self.closeWindow)

        self.mainWidget = QWidget()
        self.mainLayout = QHBoxLayout(self.mainWidget)
        self.freeSpace = QWidget()
        self.freeSpace.setStyleSheet("background-color: black")

        self.mainLayout.setSpacing(10)
        self.mainLayout.setContentsMargins(20, 20, 20, 20)
        self.mainLayout.addLayout(self.buttonLayout)
        self.mainLayout.addWidget(self.freeSpace, 1)

        self.setCentralWidget(self.mainWidget)

        self.showFullScreen()
        # screenWidth, screenHeight = pyautogui.size()
        # self.setGeometry(0,0,screenWidth+1, screenHeight)

    def openDBox(self):

        openImageFile, _ = QFileDialog.getOpenFileName()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    main_window = TestCode()
    # main_window.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.BypassWindowManagerHint)

    main_window.show()
    sys.exit(app.exec_())
SorinT
  • 53
  • 1
  • 6
  • Try adding `self` as first argument of `getOpenFileName()` (which you should always do, by the way, in order to properly make the dialog modal). Also, can you clarify if you're using the *exact* same Ubuntu distro for both architectures? If not, what are the differences? – musicamante Jun 08 '22 at 18:59
  • Sorry about the ```self```. I was in a hurry and forgot to add it. The distros are the same for both. The only difference, as far as I can tell is that one intel (works fine) and the other is ARM64 – SorinT Jun 08 '22 at 20:39
  • 1
    Then, assuming that the software configuration is the same (window manager, desktop environment, python/PyQt versions) it might be a bug caused by the underlying graphics environment. Maybe one of them runs Wayland and the other not? – musicamante Jun 08 '22 at 23:37
  • Thanks for the suggestion. I might have been wrong. I notice that the problem occurs when we use the unity environment. It works fine with gnome. I also saw this from an article talking about it. The jetson I'm using uses unity. Lxde also produces this problem in case someone encounters it – SorinT Jun 08 '22 at 23:50
  • Ok, consider that, due to the flexibility of *nix systems, window behavior can differ (sometimes, *a lot*) depending on the window manager. Also remember that you cannot set window flags for file dialogs created using the static functions of QFileDialog, since those functions create the dialogs *internally* and there is almost no control over their behavior (if not by using some "dirty hacks"). The only *safe* way to have full control over them is by using a QFileDialog subclass and *always* use the `DontUseNativeDialog` option. – musicamante Jun 09 '22 at 00:21
  • Thank you. This was very helpful. It's crazy you mention it because I was actually planning on setting flags to the static functions. The ```DontUseNativeDialog``` option really make the dialog look ugly somehow but still gets the job done when modifying it – SorinT Jun 10 '22 at 02:04
  • It's not that crazy, it's actually a common and understandable mistake. Unfortunately, you have to choose between *the best of both worlds*: you either use the system default (the "native dialog") which has the unwanted behavior, or the Qt one, which is completely based on Qt widgets and tries to follow the system style as much as possible (and that only depends on the support from the platform, which could or could not provide a custom style that is consistent with the "theme"). It could be possible to find a work around, but it would be *hack-ish* and would require implementing a "watcher"-> – musicamante Jun 10 '22 at 02:20
  • 1
    ->that waits for a new window appearing (the dialog) and eventually set its features through Xlib, but that would be extremely hard and probably not so reliable. What I can understand from your comments is that it's *probably* a bug (but could also be a choice by design). I'd suggest you to try to reach for the ubuntu support, maybe on irc, and see if they can sort this out. You might not have a solution, but at least you'd know. Note that if you don't use the native dialog you can obviously use style sheets. – musicamante Jun 10 '22 at 02:23
  • Thank you once again. I think contacting ubuntu support is what I'll do first – SorinT Jun 10 '22 at 16:52

0 Answers0