[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&nbsp;</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&nbsp;</div><div><br></div><div><div>import sys \
&nbsp;&nbsp;</div><div>from PyQt4.QtGui import *</div><div>from PyQt4.QtCore import \
*</div><div><br></div><div>if __name__ == '__main__': \
&nbsp;&nbsp;</div><div><br></div><div>&nbsp; &nbsp; app =QApplication(sys.argv) \
&nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; ui =QMainWindow() \
&nbsp;&nbsp;</div><div><br></div><div>&nbsp; &nbsp; model= QFileSystemModel () &nbsp; \
&nbsp; &nbsp;</div><div>&nbsp; &nbsp; model.setRootPath(QDir.currentPath()) \
&nbsp;</div><div><br></div><div>&nbsp; &nbsp; model.sort(3)</div><div>&nbsp; &nbsp; \
&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; table = QTableView()</div><div>&nbsp; \
&nbsp; #print(table.verticalHeader().defaultAlignment()) #</div><div>&nbsp; &nbsp; \
table.verticalHeader().setDefaultAlignment(Qt.AlignRight)</div><div><br></div><div>&nbsp; \
&nbsp; table.setModel(model); &nbsp;&nbsp;</div><div>&nbsp; &nbsp; \
table.setRootIndex(model.index(QDir.currentPath())) #&nbsp;</div><div>&nbsp; &nbsp; \
ui.setCentralWidget(table)</div><div>&nbsp; &nbsp; ui.resize(800, \
600)</div><div>&nbsp; &nbsp; ui.show() &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; \
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