I want to set the QMdiArea TabBar
width by setStyleSheet
function,but it can not set the width, it can set the height.Now I have no idea how to solve the problem, can you give me a idea?
Thanks a lot.Here is my code.
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setGeometry(0,0,600,600)
self.mdi = QMdiArea(self)
self.mdi.setGeometry(40, 40, 500, 500)
self.mdi.setViewMode(QMdiArea.TabbedView)
self.mdi.setTabShape(QTabWidget.Triangular)
self.mdi.setTabsClosable(True)
self.mdi.setDocumentMode(False)
self.mdi.setTabsMovable(True)
self.mdi.setTabPosition(QTabWidget.North)
self.mdi.setOption(QMdiArea.DontMaximizeSubWindowOnActivation)
# setStyleSheet can not set the width,but it can set the height
self.mdi.setStyleSheet("QTabBar::tab { height: 20px; width: 20px; }");
self.setWindowTitle("MDI demo")
sub = QMdiSubWindow()
sub.resize(200, 200)
sub.setWindowTitle("11")
self.mdi.addSubWindow(sub)
if __name__ == '__main__':
app = QApplication(sys.argv)
demo = MainWindow()
demo.show()
sys.exit(app.exec_())