Python Forum
PyQt6 QWidgets and system recognition of windows
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyQt6 QWidgets and system recognition of windows
#1
This concerns an application written in PyQt6, and in particular in relation to Ubuntu Linux (using Kubuntu KDE Plasma, but the same issues exist in Gnome) , though it may be an issue in Windows, MacOS, etc. but I haven't run it there.

I did not write this application; I am a user but I have access to its source code. There is a small community of users who use this program and I try to be helpful to the developer, who is not, primarily, a programmer. He is very active in making improvements and he does accept git pull requests if he likes them.

I am a retired developer with some but not vast experience in python. Not much with PyQt.

Here is my question:

This application uses several different kinds of windows. There is the main window. Others are dialogs, inheriting from QDialog. Others, the ones I am concerned about, are inherited from QWidget. The problem I have with these windows is that they are not recognized by the system as windows. I see this in two ways.

1) the system PrintScreen function (implemented on my system as the "Spectacle" application) does not consider these windows as windows, when the "Active Window" is selected to be captured as a screen shot. If I select "Active Window" that is assumed to be the main window. If I want to capture just this window, I must use the "rectangular region" option. This is not the case with the dialogs. If one of them is active, then it is the active window.

2) The system settings have settings for window borders and other such adornments. When I modify these, the setting change is applied to the main window, to dialogs, but NOT to these "mere QWidget" windows.

So here are two questions:

1) Is this a linux-related issue or would similar issues apply under Windows, MacOS. etc.?
2) It there some PyQt enhancement that could be applied to such windows in a relatively pain-free manner that would allow these windows to be recognized by the system as windows?

Thanks for your attention to this.
Reply
#2
Looking into this issue it appears to be related to some linux distributions changing display server protocols from Xorg to Wayland. This article talks about some ways to fix the problem.

https://ubuntuhandbook.org/index.php/202...ps-ubuntu/

This is not an issue with Windows.
Reply
#3
(Nov-14-2025, 06:38 PM)stevecoh1 Wrote: This application uses several different kinds of windows. There is the main window. Others are dialogs, inheriting from QDialog. Others, the ones I am concerned about, are inherited from QWidget. The problem I have with these windows is that they are not recognized by the system as windows.

It's working here in Debian13 (no wayland)

Using QDialog I can make a screenshot of active window and it is ok.

from PyQt6.QtWidgets import (QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, 
                             QWidget, QDialog)

class MainWin(QDialog):
    def __init__(self, parent = None):
        super(MainWin, self).__init__(parent)
        self.setupUI()
        
    def setupUI(self):
        self.setGeometry(0, 0, 300, 100)


if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)
    win = MainWin()
    win.setWindowTitle("QDialog")
    win.show()

    sys.exit(app.exec())
same for QMainWindow

from PyQt6.QtWidgets import (QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, 
                             QWidget)

class mainWin(QMainWindow):
    def __init__(self, parent = None):
        super(mainWin, self).__init__(parent)
        self.setupUI()
        
    def setupUI(self):
        self.setGeometry(0, 0, 300, 100)
        central_widget = QWidget()
        vbox = QVBoxLayout()
        central_widget.setLayout(vbox)
        self.setCentralWidget(central_widget)


if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)
    win = mainWin()
    win.setWindowTitle("QMainWindow")
    win.show()

    sys.exit(app.exec())
same for QWidget

from PyQt6.QtWidgets import (QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, 
                             QWidget)

class mainWin(QWidget):
    def __init__(self, parent = None):
        super(mainWin, self).__init__(parent)
        self.setupUI()
        
    def setupUI(self):
        self.setGeometry(0, 0, 300, 100)


if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)
    win = mainWin()
    win.setWindowTitle("QWidget")
    win.show()

    sys.exit(app.exec())
   
   
   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Tutorial bug with PyQt6 canvas Mike88 5 2,443 Jan-02-2025, 10:37 PM
Last Post: Mike88
  [PyQt] Saving file to html or pdf stopped working in PyQt6 ejKDE 4 4,890 Mar-12-2024, 07:45 PM
Last Post: ejKDE
  [PyQt] [solved] How to display a pdf-file in a PyQt6 widget BigMan 13 30,745 May-06-2023, 09:27 AM
Last Post: Axel_Erfurt
  event driven coding PyQt6 on Combobox change merrittr 3 5,622 May-03-2023, 03:35 AM
Last Post: merrittr
Question [PyQt] Application desktop toolbar with PyQt6 bunz 4 3,769 Mar-09-2023, 08:09 PM
Last Post: bunz
  PyQt6 QAction with icon and string malonn 2 4,091 Sep-12-2022, 11:59 AM
Last Post: malonn
  [PyQt] Embed Google Maps in PyQt6 Widget Raures 2 5,067 Sep-11-2021, 04:32 PM
Last Post: Raures
  Change resolution of windows system sarangj 3 4,838 Jul-04-2018, 08:23 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020