[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] header view question when QFileSystemModel is displayed in a QTableView
From: "=?ISO-8859-1?B?aU1hdGg=?=" <2281570025 () qq ! com>
Date: 2013-11-15 14:12:35
Message-ID: tencent_44FC83335076BF740EC1CE5D () qq ! com
[Download RAW message or body]
[Attachment #2 (multipart/related)]
[Attachment #4 (multipart/alternative)]
[Attachment #6 (text/plain)]
when the contents of the QFileSystemModel is displayed in a QTableView , the \
alignment of the text in the first row header section is right-aligned ,while the \
others is left-aligned,I wonder why ?
how to make the alignment of the text in each header section to be left-aligned?
setDefaultSectionSize() seems doesn't work here
my code
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
if __name__ == '__main__':
app =QApplication(sys.argv)
ui =QMainWindow()
model= QFileSystemModel ()
model.setRootPath(QDir.currentPath())
model.sort(3)
table = QTableView()
#print(table.verticalHeader().defaultAlignment()) #
table.verticalHeader().setDefaultAlignment(Qt.AlignRight)
table.setModel(model);
table.setRootIndex(model.index(QDir.currentPath())) #
ui.setCentralWidget(table)
ui.resize(800, 600)
ui.show()
app.exec_()
[Attachment #7 (text/html)]
<div><span style="line-height: 1.5;">when the contents of the QFileSystemModel is \
displayed in a QTableView , the alignment of the text in the first row header section \
is right-aligned ,while the others is </span><span style="line-height: \
1.5;">left-aligned,I wonder why ?</span></div><div><img \
src="cid:2E49FB4A@FD261F29.D32B8652.jpg" filesize="16473"></div><div>how to make the \
alignment of the text in each header section to be \
left-aligned?</div><div><br></div><div>setDefaultSectionSize() seems doesn't work \
here</div><div><br></div><div>my code </div><div><br></div><div><div>import sys \
</div><div>from PyQt4.QtGui import *</div><div>from PyQt4.QtCore import \
*</div><div><br></div><div>if __name__ == '__main__': \
</div><div><br></div><div> app =QApplication(sys.argv) \
</div><div> ui =QMainWindow() \
</div><div><br></div><div> model= QFileSystemModel () \
</div><div> model.setRootPath(QDir.currentPath()) \
</div><div><br></div><div> model.sort(3)</div><div> \
</div><div> table = QTableView()</div><div> \
#print(table.verticalHeader().defaultAlignment()) #</div><div> \
table.verticalHeader().setDefaultAlignment(Qt.AlignRight)</div><div><br></div><div> \
table.setModel(model); </div><div> \
table.setRootIndex(model.index(QDir.currentPath())) # </div><div> \
ui.setCentralWidget(table)</div><div> ui.resize(800, \
600)</div><div> ui.show() </div><div> \
app.exec_()</div></div><div><br></div>
["2E49FB4A@FD261F29.D32B8652.jpg" (image/jpeg)]
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic