Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Header view when QFileSystemModel is displayed in a QTableView
Forum Updated to NodeBB v4.3 + New Features

Header view when QFileSystemModel is displayed in a QTableView

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    redstoneleo
    wrote on last edited by
    #1

    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 ? enter image description here
    !http://i.stack.imgur.com/ohJ9u.jpg(pic)!
    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_()
    

    @

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved