2017-11-27 6 views
0

내가 WIN7 32 비트에 다음 코드를 사용할 때 일어난은 (테스트) 긴 이름을 가진 하나 개의 파일 만QTableView 항목은 다르게 PyQt는 5.8에서 무승부를 기록했고 5.9

import sys 
from PyQt5.QtCore import * 
from PyQt5.QtGui import * 
from PyQt5.QtWidgets import * 


if __name__ == '__main__': 

    app = QApplication(sys.argv) 
    # ui = QMainWindow() 

    path = r'D:\BaiduYunDownload\untitled' 
    model = QFileSystemModel() 
    model.setRootPath(path) 

    table = QTableView() 
    table.setModel(model) 
    table.setRootIndex(model.index(path)) 

    # ui.setCentralWidget(table) 
    table.resize(800, 600) 
    table.show() 

    viewOptions = table.viewOptions() 
    print(table.wordWrap(), 
      int(viewOptions.textElideMode), 
      int(viewOptions.decorationAlignment), 
      int(viewOptions.displayAlignment), 
      int(viewOptions.features)) 

    app.exec_() 

가 : A directory model that displays the contents of a default directory is usually constructed with a parent object.txt 에서 DIR D:\BaiduYunDownload\untitled PyQt는 5.8

는 PyQt는 5.9.1에서 enter image description here

(통해 설치 (설치 pip3 install pyqt5==5.8 통해) Name 열에서 QTableView 항목이 무승부가 다른 이유) enter image description here

내가 궁금해? 코드에서 다음과 같은 프로퍼티로 체크했는데, 모두 PyQt의 두 버전 모두에서 같은 값을 반환했습니다.

print(table.wordWrap(), 
int(viewOptions.textElideMode), 
int(viewOptions.decorationAlignment), 
int(viewOptions.displayAlignment), 
int(viewOptions.features)) 

답변

1

Qt 버그 인 것 같습니다. Qt의 버그보고 here을 확인하십시오.

한 가지 해결 방법은 CSS를 통해 글꼴 속성을 설정하는 것입니다.