zhiyiYo / PyQt-Fluent-Widgets

A fluent design widgets library based on C++ Qt/PyQt/PySide. Make Qt Great Again.
https://qfluentwidgets.com
GNU General Public License v3.0
5.65k stars 544 forks source link

[Bug]: Opening UI Files in fluent window #788

Closed Jake4353 closed 7 months ago

Jake4353 commented 7 months ago

What happened?

Is it possible to load a ui file within a FluentWindow or Frameless window as it returns this error when i try to load it.

raise TypeError(TypeError: ('Wrong base class of toplevel widget', (<class '__main__.Ui'>, 'QMainWindow'))

But if i do a normal QMainWindow it works, But the only issue i have is the default window frame image

Operation System

Windows 11 23H2

Python Version

3.10.10

PyQt/PySide Version

pyqt5 5.15.9

PyQt/PySide-Fluent-Widgets Version

1.5.1

How to Reproduce?

Run a ui file containing a Fluent widget with the code.

Minimum code

import sys
from PyQt5 import uic, QtWidgets

# from qframelesswindow import FramelessWindow
# from qfluentwidgets import FluentWindow

# class Ui(FramelessWindow):
# class Ui(FluentWindow):
class Ui(QtWidgets.QMainWindow):
    def __init__(self):
        super(Ui, self).__init__()
        uic.loadUi('main.ui', self)
        self.show()

app = QtWidgets.QApplication(sys.argv)
window = Ui()
app.exec_()
Cheukfung commented 7 months ago

It could be that the class of your UI file is not QWidget. I tested it and there was no problem. You can upload your UI file.