[PyQt] header view question when QFileSystemModel is displayed in a QTableView

iMath 2281570025 at qq.com
Fri Nov 15 14:12:35 GMT 2013


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_()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20131115/94b42012/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2E49FB4A at FD261F29.D32B8652.jpg
Type: image/jpeg
Size: 16473 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20131115/94b42012/attachment-0001.jpg>


More information about the PyQt mailing list