Unsolved Custom Button is not styled by the Material theme
-
Hello,
I need to create a custom button, which uses as a root element a regular button from QtQuick.Controls 2. Inside this new component, called ButtonWithHelp.qml, I've added some additional functionality.
Something along the lines:import QtQuick 2.12 import QtQuick.Controls 2.12 Button { id: customControl contentItem: //code here background: //some more code here }
Everything works as expected, except the styling. In main.cpp I set the style by doing
QQuickStyle::setStyle("Material");
which modifies all the other buttons except when using ButtonWithHelp.
I do not want to manually define the colors inside the component as I hope to have a general style which should be applicable at runtime.
Does anyone know what needs to be done?
Thank you.
Florin -
which operating system are you using?
if it's win10 you can only use "windowVisa" , "Windows" and "Fusion" -
@nullbuil7 this question is about Qt Quick, not QWidgets. The styles are not dependent on the platform.
Button { id: customControl contentItem: //code here background: //some more code here }
Qt Quick Controls styles use their own contentItem and background to style a control, you are overriding them here.
What do you want to actually achieve by customysing the controls?