Issue
I have a simple code that Creates a QTableWidget. Problem is when I resize the window, columns of QTableWidget are not automatically adjusted to fit entire screen
Please find the snippet below:
from PySide.QtCore import *
from PySide.QtGui import *
import sys
app = QApplication(sys.argv)
table = QTableWidget(1,3)
table.show()
sys.exit(app.exec_())
Solution
The one that controls the width of the columns is the horizontalHeader()
, the solution is to set QHeaderView::Stretch
using the method setResizeMode()
.
import sys
from PySide.QtGui import QApplication, QTableWidget, QHeaderView
import sys
if __name__ == '__main__':
app = QApplication(sys.argv)
table = QTableWidget(1,3)
table.horizontalHeader().setResizeMode(QHeaderView.Stretch)
table.show()
sys.exit(app.exec_())
Answered By - eyllanesc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.