Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 最大化窗口 #181

Open
Mxx-001 opened this issue Feb 10, 2025 · 0 comments
Open

[Bug]: 最大化窗口 #181

Mxx-001 opened this issue Feb 10, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Mxx-001
Copy link

Mxx-001 commented Feb 10, 2025

Describe the bug
pyside6下直接以最大化窗口运行代码,不能正常缩小放大窗口。(pyqt5正常)

Environment
环境信息

  • OS: win11 24H2
  • DPI scaling: 150% (2560*1600)
  • Python: 3.9.21
  • PySide6: 6.8.2.1

To Reproduce
window.showMaximized()

2025-02-10.092310.mp4

Code
最小复现代码

# coding:utf-8
import sys

from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication, QLabel, QMenuBar, QMenu, QStatusBar, QTextEdit, QHBoxLayout

from qframelesswindow import FramelessMainWindow, FramelessDialog


class MainWindow(FramelessMainWindow):

    def __init__(self):
        super().__init__()
        self.setWindowTitle("Frameless Main Window")

        # add menu bar
        menuBar = QMenuBar(self.titleBar)
        menu = QMenu('File(&F)', self)
        menu.addAction('open')
        menu.addAction('save')
        menuBar.addMenu(menu)
        menuBar.addAction('Edit(&E)')
        menuBar.addAction('Select(&S)')
        menuBar.addAction('Help(&H)', self.showHelpDialog)
        self.titleBar.layout().insertWidget(0, menuBar, 0, Qt.AlignLeft)
        self.titleBar.layout().insertStretch(1, 1)
        self.setMenuWidget(self.titleBar)

        # add status bar
        statusBar = QStatusBar(self)
        statusBar.addWidget(QLabel('row 1'))
        statusBar.addWidget(QLabel('column 1'))
        self.setStatusBar(statusBar)

        # set central widget
        self.textEdit = QTextEdit()
        self.setCentralWidget(self.textEdit)

        self.setStyleSheet("""
            QMenuBar{background: #F0F0F0; padding: 5px 0}
            QTextEdit{border: none; font-size: 15px}
            QDialog > QLabel{font-size: 15px}
        """)

    def showHelpDialog(self):
        w = FramelessDialog(self)

        # add a label to dialog
        w.setLayout(QHBoxLayout())
        w.layout().addWidget(QLabel('Frameless Dialog'), 0, Qt.AlignCenter)

        # raise title bar
        w.titleBar.raise_()
        w.resize(300, 300)

        # disable resizing dialog
        w.setResizeEnabled(False)
        w.exec()


if __name__ == '__main__':
    # enable dpi scale
    QApplication.setHighDpiScaleFactorRoundingPolicy(
        Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)

    app = QApplication(sys.argv)

    # fix issue #50
    app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)

    window = MainWindow()
    window.showMaximized()
    app.exec()

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

@Mxx-001 Mxx-001 added the bug Something isn't working label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant