QLineEdit - wrong placeholderText's color on Linux Mint dark theme
-
Hi,
I have Linux Mint 22.1 Cinnamon with dark theme Mint-Y.
When creating UI, in design I see correct gray color for placeholderText:
But when I run app:
Why it is like that? It is default Qt Widgets App so I guess it is using Fusion Style. Everything else is perfect, just like GTK, green accent colors etc. Note that I have some Qt apps already installed for example Keepassx which is Qt and placeholders also have correct gray color. All other native GTK apps also have gray placeholders.
I had this issue on Qt 6.8 and now updated to 6.9 it is still -
Hi,
Which version of Qt is provided by your distribution ?
Did you try to build your application with it ? -
You can give PhantomStyle a try.
Phantom is a QStyle for Qt which began as an overhaul of QFusionStyle. Similar to Fusion, it's designed to be a looks-the-same cross-platform style. It looks native to nobody, but familiar to many. It has the visual appearance of a traditional GUI, and does not adopt a "modern flat" style. Compared to Fusion, it has many fixes, objective improvements, and subjective improvements.
I have packaged a Qt Creator plugin https://github.com/cristianadam/qt-creator-phantomstyle which uses PhantomStyle. So that you can see it in action.
If you want to use it in your application you can add these lines to your
CMakeLists.txt
:include(FetchContent) FetchContent_Declare(PhantomStyle GIT_REPOSITORY "https://github.com/cristianadam/phantomstyle.git") FetchContent_MakeAvailable(PhantomStyle) target_link_libraries(<CoolApp> PRIVATE PhantomStyle)
and in your
main.cpp
:// ... #include <phantom/phantomstyle.h> int main() { // ... QApplication::setStyle(new PhantomStyle); // ... }
KeePassXC is using a variation of PhantomStyle.
By having your own style, you can modify it to your eyes desire 😊
-
Hi,
Which version of Qt is provided by your distribution ?
Did you try to build your application with it ?@SGaist said in QLineEdit - wrong placeholderText's color on Linux Mint dark theme:
Hi,
Which version of Qt is provided by your distribution ?
Did you try to build your application with it ?Seems that installing Keepassx (I think it is the only Qt app which I installed from Mint repo, other ones are from flatpak) I got 5.15.13 as dependency packages:
qmake --version QMake version 3.1 Using Qt version 5.15.13 in /usr/lib/x86_64-linux-gnu
Command
dpkg -l | grep qt
also return similar packages:
I didn't try to compile on these versions yet
@cristian-adam Can you provide
.pro
example? C++ is my secondary language and I'm polishing it on Qt where I mostly use qmake and.pro
. Even if Phanton fix the problem, it is sad that so silly placeholderText has this problem in default Qt Style -
I think it has something to do with the default palette, which can vary from operating system to operating system.
If I look at https://doc.qt.io/qt-6/qpalette.html it could be that for some entry, like
QPalette::PlaceholderText
the light theme color value is being used instead of the dark theme one. -
You can change the
QPalette::PlaceholderText
to something else, see:int main(int argc, char *argv[]) { QApplication a(argc, argv); QPalette pal = QApplication::palette(); pal.setColor(QPalette::PlaceholderText, pal.color(QPalette::Mid)); QApplication::setPalette(pal);
-
Thank you @cristian-adam . Found something interesting. The
QPalette::Mid
was too much alike to edit background so I played with different types to get something close to GTK placeholder color. Finally did something stupid just for curiosity:int main(int argc, char *argv[]) { QApplication a(argc, argv); //QApplication::setStyle(new PhantomStyle); QPalette pal = QApplication::palette(); pal.setColor(QPalette::PlaceholderText, pal.color(QPalette::PlaceholderText)); QApplication::setPalette(pal); MainWindow w; w.show(); return a.exec(); }
And the result is:
What happened there? Palette don't have initialized color for
QPalette::PlaceholderText
color role? -
It looks like a bug. Please do open up a bug report at https://bugreports.qt.io
Hopefully the Qt Widgets maintainers have more ideas why this is happening. But now you have a workaround.
Does:
QPalette pal = QApplication::palette(); QApplication::setPalette(pal);
work? Or you have to explicitly set
QPalette::PlaceholderText
? -
-
You should check it with a recent Qt version first before creating a bug report
-
In your images above you use Qt5
-
Ok, then all is fine, create a bug report. Looks like a problem with the gtk platform plugin.
Maybe it's also related to https://bugreports.qt.io/browse/QTBUG-86195 -
Created ticket if someone come here with similar problem:
https://bugreports.qt.io/browse/QTBUG-136075 -
Ok, then all is fine, create a bug report. Looks like a problem with the gtk platform plugin.
Maybe it's also related to https://bugreports.qt.io/browse/QTBUG-86195@Christian-Ehrlicher said in QLineEdit - wrong placeholderText's color on Linux Mint dark theme:
Ok, then all is fine, create a bug report. Looks like a problem with the gtk platform plugin.
Maybe it's also related to https://bugreports.qt.io/browse/QTBUG-86195Weird, I searched first for placeholdertext keyword and didn't find anything. Anyway, that one is for Windows 10 reported in 2023
-
@Christian-Ehrlicher said in QLineEdit - wrong placeholderText's color on Linux Mint dark theme:
Ok, then all is fine, create a bug report. Looks like a problem with the gtk platform plugin.
Maybe it's also related to https://bugreports.qt.io/browse/QTBUG-86195Weird, I searched first for placeholdertext keyword and didn't find anything. Anyway, that one is for Windows 10 reported in 2023
@Kobid said in QLineEdit - wrong placeholderText's color on Linux Mint dark theme:
Anyway, that one is for Windows 10 reported in 2023
Please read the full bug report. It's also for linux.