Visual differences in StyledPanel QFrames between flatpak and native build
-
Hey everybody,
i am developing a Qt application (currently using Qt 5.15) which i am planning to publish as a flatpak using version 5.15-23.08 of the org.kde.Platform runtime. I have noticed a few visual differences between the flatpak version and the native version. More specifically, derivatives of QFrame, such as QTableView, are not drawn correctly in the flatpak version when setting the frame shape to QFrame::StyledPanel. In most cases these widgets lack a proper frame border, but at least one such widget looks identical in both versions.This is the native build where everything looks as intended:
This is the flatpak build which has some visual differences. Please note that differences in the content of the tables are due to the flatpak sandbox and are intendeed. Arrow 1 shows a missing frame border around a QTableView, arrow 2 shows a missing frame border and wrong background color for a QFrame and arrow 3 shows a horizontal line that only exists in the flatpak version.
Here is a different QTableView in the flatpak version that is drawn as intended with a border:
As far as i understand, the visuals of these elements are determined by the style set for QApplication. Running
qDebug() << QApplication::style()->objectName();
outputs "breeze", which is the native style of the KDE Plasma desktop i am using, for both versions of the app . Changing this style in the system options correctly updates the look of both versions, so the flatpak version seems to be able to access system styles.
As i am relatively new to both Qt and flatpak, i don't know of a good way to debug this issue. Has anybody here run into a similar issue or knows of a way to debug this?
-
The difference is the platform theme.
If you launch your application in a KDE environment, the KDE platform theme is loaded. Within a flatpak, you have a GTK environment. So the GTK 3 platform theme is loaded. Both can have breeze as a base style. There is nothing missing, it’s just a different environment. -
Thank you.
That explains most of my issues, but i still don't understand why only some of the QTableViews have borders drawn around them in the flatpak version. Is there a way to ensure that all QTableViews consistently have a border, as seen in the third screenshot? -
I don’t know, which is the exact gnome environment in your flatpak and how this table view is created.
The frame in screenshot 3 looks like a focus frame to me. -
I managed to fix the issue. The flatpak version only draws StyledPanal frame shadows when the parent widget is using a grid layout where at least one of the spacing values (horizontal or vertical) is not 0. Any other layout (VBox, HBox, Splitter or Dialog ) and the frame shadows are not drawn. So the fix in my case was to place each of my QTableViews inside of an otherwise empty QWidget that uses a grid layout with any non 0 spacing (negative values work as well).