Missing Borders on Widgets after PySide2 -> PySide6 Migration
-
Working on migrating a PySide2 application to PySide6, and noticed some weird widget appearance behavior after replacing the PySide2 imports with PySide6 at the top of the application file. In particular, some widgets in my grid layout are missing their left and, sometimes top, borders. See images below (PySide2 is first, PySide6 is second).
It also appears that the header cells on one table picked up white separators that didn't exist before, but the other one didn't. Anyone else notice weird glitches like this? Thanks.
-
Hi and welcome to devnet,
On which OS are you seeing this ?
Which version of PySide6 exactly ?
Are you installing it through pip or conda ? -
Hello,
I'm using
Windows 10 Pro, Version 10.0.18363 Build 18363
PySide 6.2.1 (6.2.2.1 still has the issue, and QTableWidgets are ugly in versions >= 6.2.2)
Installing through pip -
Can you provide a minimal script that shows this behaviour ?
-
This is about as minimal as I can get it. I removed pretty much everything from the app, except for the main view that I screenshotted. I even removed my subclassed QWidgetTables in favor of stock ones.
# PySide2 from PySide6.QtCore import * from PySide6.QtGui import * from PySide6.QtWidgets import * # Utility import sys class App(QMainWindow): def __init__(self, width, height): super().__init__() ### IMPORTANT ATTRIBUTES ### self.content = QWidget() self.setFixedSize(width, height) self.setCentralWidget(self.content) ### ELEMENTS & LAYOUT ### # Elements self.rx_table = QTableWidget() self.rx_table.setRowCount(6) self.rx_table.setColumnCount(7) self.coeff_table = QTableWidget() self.coeff_table.setRowCount(12) self.coeff_table.setColumnCount(2) self.sag_table = QTableWidget() self.sag_table.setRowCount(4) self.sag_table.setColumnCount(3) open_button = QPushButton('Open') print_button = QPushButton('Print') layout_button = QPushButton('Layout') sketch_button = QPushButton('Lens') # Layout layout = QGridLayout() layout.addWidget(QLabel(), 0, 0, 6, 1) layout.addWidget(self.rx_table, 6, 0, 6, 1) layout.addWidget(self.coeff_table, 0, 1, 9, 4) layout.addWidget(self.sag_table, 9, 1, 2, 4) layout.addWidget(open_button, 11, 1) layout.addWidget(print_button, 11, 2) layout.addWidget(layout_button, 11, 3) layout.addWidget(sketch_button, 11, 4) self.content.setLayout(layout) self.show() if __name__ == '__main__': app = QApplication(sys.argv) # Attempt to size the window according to screen resolution screen = app.primaryScreen() rect = screen.size() width = rect.width() height = rect.height() width = int(0.70*width) height = int(width/1.78) window = App(width, height) sys.exit(app.exec())
The bottom right table has all of its borders. The one above it is missing its top border. And the one on the left is missing its left border and its top. Here's the same app with the PySide6 references replaced with PySide2
The only other difference in the code is that I have to add the following lines to the PySide2 version for my high dpi screen. PySide6 handles this automatically. And even if I do leave them in the PySide6 code, the result is the same.
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True) -
Anyone? Can someone else run the minimal working example code I posted and tell me if they see the missing borders too? I'd like to know if this is a bug in PySide6 or if I'm doing something incorrectly. Thanks.
-
That might be something Windows specific. I just tested with PySide 6.2.21 and 6.2.3 on macOS and three QTableViews are showing correctly.