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

动态加载ui文件怎么使用无边框窗口 #141

Closed
npccpn opened this issue Jan 30, 2024 · 5 comments
Closed

动态加载ui文件怎么使用无边框窗口 #141

npccpn opened this issue Jan 30, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@npccpn
Copy link

npccpn commented Jan 30, 2024

动态加载ui文件怎么使用无边框窗口
pyqt5

import sys

from PyQt5 import uic
from PyQt5.QtWidgets import QApplication
from qframelesswindow import FramelessWindow

import login_student

class LoginWindow(FramelessWindow):

    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = uic.loadUi("ui/login.ui")
        self.ui.setWindowTitle("PyQt-Frameless-Window")
        self.titleBar.raise_()
        

if __name__ == '__main__':
    app = QApplication(sys.argv)
    login = LoginWindow()
    login.ui.show()
    sys.exit(app.exec_())

我以为是这样,但是运行了还是原来的边框效果orz,求大佬指点QAQ

@npccpn npccpn added the bug Something isn't working label Jan 30, 2024
@zhiyiYo
Copy link
Owner

zhiyiYo commented Feb 9, 2024

你是不是在 ui 文件里面设置了窗口属性?

@npccpn
Copy link
Author

npccpn commented Feb 9, 2024

我之前那个已经删掉了,重新试了一个新窗口,ui这样写好像更合适?运行之后能看出来最小化最大化和关闭按钮已经变了,但是窗口标题显示不出来,把ui的LayoutTopMargin设置为32也显示不了╥﹏╥除了这个以外其他没有设置什么窗口属性诶

class CheckStudentWidget(FramelessWindow):

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        uic.loadUi("ui/teacher_check.ui", self)
        self.setWindowTitle("PyQt-Frameless-Window")
        self.titleBar.raise_()


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)
    w = CheckStudentWidget()
    w.show()
    app.exec_()

![image](https://github.com/zhiyiYo/PyQt-Frameless-Window/assets/90997762/9624bdc1-2ba8-4d62-adb4-dc9eb4efcbd6)


@npccpn
Copy link
Author

npccpn commented Feb 9, 2024

QQ截图20240209175522

@Cheukfung
Copy link
Contributor

把ui文件编译为py再运行吧,反正你都设计好了界面了,参考这个新手模板:https://github.com/Cheukfung/pyqt-fluent-widgets-template

@npccpn
Copy link
Author

npccpn commented Mar 1, 2024

噢噢好的,主要是我很难确定界面,经常要调试ui╥﹏╥

@zhiyiYo zhiyiYo closed this as completed Mar 6, 2024
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

3 participants