There is a plugin for Qt Creator whose UI is just an ActiveX.
The problem is if a user changes the Qt Creator theme, the ActiveX doesn't reflect it.
That is why I need to pass information about colors to the ActiveX, but for that, the plugin has to read theme colors information. Also, the plugin needs to be notified when a current theme has just changed.
I am absolutely a newbie in Qt. Suddenly, I have not found an API to read theme colors.
Is there a way to get current theme colors from a Qt Creator plugin, and how to catch when the theme just changed?
There is
src/libs/utils/theme/theme.h
which contains theUtils::Theme
class and functionUtils::Theme *Utils::creatorTheme()
.Let the plugin depend on the Utils library (with qmake add
QTC_LIB_DEPENDS += utils
, with CMake addUtils
toDEPENDS
) and include with#include <utils/theme/theme.h>
in the source where you want to access the theme.Get the theme with
Utils::creatorTheme()
. Note that this is set up in Core plugin'sinitialize
method, so it is not available in your Plugin's constructor, but only ininitialize
and later (see Plugin Life Cycle).You can then query the
Theme
for theTheme::palette()
and the various other task-specific colors.The theme can not change during runtime, so you are safe with just querying this during startup (or at a later time where you need to set your things up.