pyqt5的界面风格怎么更改
时间: 2024-01-25 08:38:01 浏览: 121
PyQt5提供了多种界面风格,可以通过QApplication.setStyle()函数来更改界面风格。常用的几种界面风格如下:
1. Fusion风格:
```python
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QStyleFactory
app = QApplication([])
app.setStyle(QStyleFactory.create('Fusion'))
```
2. Windows风格:
```python
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QStyleFactory
app = QApplication([])
app.setStyle(QStyleFactory.create('Windows'))
```
3. WindowsVista风格:
```python
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QStyleFactory
app = QApplication([])
app.setStyle(QStyleFactory.create('WindowsVista'))
```
4. Macintosh风格:
```python
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QStyleFactory
app = QApplication([])
app.setStyle(QStyleFactory.create('Macintosh'))
```
5. GTK+风格:
```python
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QStyleFactory
app = QApplication([])
app.setStyle(QStyleFactory.create('GTK+'))
```
你可以根据自己的需要选择不同的界面风格。
阅读全文