0
나는 비슷한 질문을 이미했습니다. here하지만 qtablewigets에 레이아웃을 추가하는 적절한 방법을 알고 싶습니다. 또한 두 테이블 위젯을 나란히 놓고 같은 창에 나란히 놓을 수도 있습니다. 열.pyqt에서 qtablewidget에 레이아웃을 추가하는 적절한 방법은 무엇입니까?
나는 비슷한 질문을 이미했습니다. here하지만 qtablewigets에 레이아웃을 추가하는 적절한 방법을 알고 싶습니다. 또한 두 테이블 위젯을 나란히 놓고 같은 창에 나란히 놓을 수도 있습니다. 열.pyqt에서 qtablewidget에 레이아웃을 추가하는 적절한 방법은 무엇입니까?
테이블을 QHBoxLayout
내에 배치하십시오.
코드 :
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
class Window(QtGui.QWidget):
def __init__(self, parent=None):
super(Window, self).__init__(parent=parent)
QtGui.QTableWidget.setMinimumSize(self, 500, 500)
QtGui.QTableWidget.setWindowTitle(self, "Custom table widget")
self.table1 = QtGui.QTableWidget()
self.configureTable(self.table1)
self.table2 = QtGui.QTableWidget()
self.configureTable(self.table2)
self.buttonBox = QtGui.QDialogButtonBox(self)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok)
self.verticalLayout = QtGui.QVBoxLayout(self)
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.addWidget(self.table1)
self.horizontalLayout.addWidget(self.table2)
self.verticalLayout.addLayout(self.horizontalLayout)
self.verticalLayout.addWidget(self.buttonBox)
self.buttonBox.accepted.connect(self.close)
self.buttonBox.rejected.connect(self.close)
def configureTable(self, table):
rowf = 3
table.setColumnCount(3)
table.setRowCount(rowf)
table.setHorizontalHeaderItem(0, QtGui.QTableWidgetItem("col1"))
table.setHorizontalHeaderItem(1, QtGui.QTableWidgetItem("col2"))
table.setHorizontalHeaderItem(2, QtGui.QTableWidgetItem("col3"))
table.horizontalHeader().setStretchLastSection(True)
# table.verticalHeader().setStretchLastSection(True)
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())
이미지 :
너무 감사합니다! 해피 홀리데이와 메리 크리스마스. – answerSeeker
다른 질문에 답할 수 있습니까? http://stackoverflow.com/questions/41340061/how-can-i-connect-a-pages-function-to-a-quawizards-next-button – answerSeeker