[SOLVED] fusion style, palette and controls no longer showing disabled state



  • I'm experimenting with style/palettes.
    I've added this to main.cpp and really quite like the resulting look. The problem though is that checkboxes, input fields, sliders (etc) all end up looking exactly the same when they are disabled as they do when enabled. What have I done wrong, or what do I need to add?

    edit: I'm using Qt5.3 on Windows

    Thanks!

    @ qApp->setStyle(QStyleFactory::create("Fusion"));

    QPalette darkPalette;
    darkPalette.setColor(QPalette::Window, QColor(53,53,53));
    darkPalette.setColor(QPalette::WindowText, Qt::white);
    darkPalette.setColor(QPalette::Base, QColor(25,25,25));
    darkPalette.setColor(QPalette::AlternateBase, QColor(53,53,53));
    darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
    darkPalette.setColor(QPalette::ToolTipText, Qt::white);
    darkPalette.setColor(QPalette::Text, Qt::white);
    darkPalette.setColor(QPalette::Button, QColor(53,53,53));
    darkPalette.setColor(QPalette::ButtonText, Qt::white);
    darkPalette.setColor(QPalette::BrightText, Qt::red);
    darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
    darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
    darkPalette.setColor(QPalette::HighlightedText, Qt::black);
    
    qApp->setPalette(darkPalette);
    

    @


  • Lifetime Qt Champion

    Hi,

    Calling setColor like that puts the same color for all states, you have to use the other version giving the color group.

    Hope it helps



  • [quote]you have to use the other version giving the color group.[/quote]

    Hi, can you show me an example of what this means?
    Thank you


  • Lifetime Qt Champion



  • Ahh gotcha, I see how it works now.

    Solution - I need to do like this in addition to that which I described in the first post;

    darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(77,98,120));
    etc...--

    Thanks!


  • Lifetime Qt Champion

    You're welcome !

    If you have your colors working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.