我想改变 Qtablewidget 的方向从右到左
I would like to change a direction of Qtablewidget From Right to left
我需要让 Qtablewidget 从右到左开始,这意味着右侧的 verticalHeader()
self.table = QTableWidget()
self.table.setGeometry(0 , 0 , 700 , 700)
self.table.setColumnCount(4)
self.table.setRowCount(30)
self.table.setHorizontalHeaderLabels(['يومى', 'الاسبوع' , 'الشهرى' , 'المادة'])
self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
layoutDirection : Qt::LayoutDirection
This property holds the default layout direction for this application
On system start-up, the default layout direction depends on the application's language.
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
class MyWin(QMainWindow):
def __init__(self, parent=None):
super(MyWin, self).__init__()
central_widget = QWidget()
self.setCentralWidget(central_widget)
self.table = QTableWidget(central_widget)
self.table.setGeometry(0 , 0 , 700 , 700)
self.table.setColumnCount(4)
self.table.setRowCount(30)
self.table.setHorizontalHeaderLabels(['يومى1', 'الاسبوع2' , 'الشهرى3' , 'المادة4'])
self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setLayoutDirection(Qt.RightToLeft) # <-------------------
w = MyWin()
w.resize(700, 700)
w.show()
sys.exit(app.exec_())
我需要让 Qtablewidget 从右到左开始,这意味着右侧的 verticalHeader()
self.table = QTableWidget()
self.table.setGeometry(0 , 0 , 700 , 700)
self.table.setColumnCount(4)
self.table.setRowCount(30)
self.table.setHorizontalHeaderLabels(['يومى', 'الاسبوع' , 'الشهرى' , 'المادة'])
self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
layoutDirection : Qt::LayoutDirection
This property holds the default layout direction for this application
On system start-up, the default layout direction depends on the application's language.
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
class MyWin(QMainWindow):
def __init__(self, parent=None):
super(MyWin, self).__init__()
central_widget = QWidget()
self.setCentralWidget(central_widget)
self.table = QTableWidget(central_widget)
self.table.setGeometry(0 , 0 , 700 , 700)
self.table.setColumnCount(4)
self.table.setRowCount(30)
self.table.setHorizontalHeaderLabels(['يومى1', 'الاسبوع2' , 'الشهرى3' , 'المادة4'])
self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setLayoutDirection(Qt.RightToLeft) # <-------------------
w = MyWin()
w.resize(700, 700)
w.show()
sys.exit(app.exec_())