Default Controls Style not the same as no style given



  • Hi,
    I have a question regarding the default style used by Controls (under Windows 7 / 8, not tested under other platforms). When I create a Slider {} or make a Slider { style: SliderStyle {} } I don't end up with the same widget at all (used the slider since it's probably one of the most visual obvious one).

    I was wondering which style is used by default for the widget (Base, Desktop...)? Any way to used it or make it with style like SliderStyle?

    This make it hard to make a simple modif to style and keep a coherent look with the not styled controls.

    We have a fully skinned style or offer native style into the application and can switch between both during runtime. The native look with a few modif (like font size) is the part where things get ugly.

    Thanks,
    Jerome


  • Moderators

    Hi,

    It works on Ubuntu 14.04 with Qt 5.3.1
    Here's a screenshot:
    !http://i.imgur.com/Zn3Pzbg.png(screenshot)!

    Here's the code with which i tested
    @
    import QtQuick 2.2
    import QtQuick.Controls 1.2
    import QtQuick.Controls.Styles 1.2

    Item {
    width: 360
    height: 260

    Button {
        id: a
        text: "click"
    }
    
    Button {
        anchors.left: a.right
        text: "click"
        style: ButtonStyle { }
    }
    
    Slider {
        id: b
        anchors.top: a.bottom
    }
    
    Slider {
        anchors.left: b.right
        anchors.top: a.bottom
        style: SliderStyle { }
    }
    
    CheckBox {
        id: c
        anchors.top: b.bottom
    }
    
    CheckBox {
        anchors.left: c.right
        anchors.top: b.bottom
        style: CheckBoxStyle { }
    }
    

    }
    @

    May be it could be a problem on Windows.



  • I am afraid this is by design. The style delegates you get by importing QtQuick.Controls.Styles are cross-platform and do not match any specific desktop style. This makes it possible to re-use the custom styles you make across multiple platforms.

    If you have a strong desire to use the low level native styling, you can in principle access the undocumented "StyledItem" from the QtQuick.Controls.Private import. Needless to say this is not documented or supported.



  • Here's the same code as p3c0 above but under Windows 7 and Qt 5.3.1 (look like a Windows only problems, not tested on OS X yet will try to update it soon):
    !http://i.imgur.com/35kdWmK.png(Windows Style)!

    Which one is correct does not really matter to me, it's just a consistency problem here, I have a full custom style which can be used, we just want to be able to offer default platform look also. For Windows I guess I will have to provide a style for every controls (no matter what).



  • Look like the deafult style like ButtonStyle {} is loading the plastic theme look alike of Windows and the no style is the default Windows theme. My computer is not set to use the plastic theme btw. If that may help.



  • Hi Jerome,

    On Windows and Mac OS X, there is the "Desktop" style. "Base" style is used on Linux / on platforms that have no specific style.
    When you do
    @
    import QtQuick.Controls.Styles 1.2
    @

    you will import the "Base" styles. So
    @
    style: ButtonStyle { }
    @

    will override the loaded "Desktop" style.
    To modify the "Desktop" style, replace the
    @
    import QtQuick.Controls.Styles 1.2
    @

    with
    @
    import "qrc:/QtQuick/Controls/Styles/Desktop"
    @

    Note that this is NOT an official way/API and can change with new Qt versions.



  • Thanks for the information, that's clarify the observed behavior.


Log in to reply
 

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