Hovercraft 2

  • Hi,

    Who knows if Qt Script styled pushbuttons, act on hover and pressed styles ?

    I'm using Qt Script only, so just a .js and .ui - our vendor tool launches the .js,
    which then loads a .ui via special command.

    Everything Qt I've tried works, except for this:

    I have 2 buttons: one unstyled, and one styled. The unstyled (ie stylesheet empty), when I hover or press it, visually changes.

    But the styled one visually does nothing, despite my trying configuring hover and pressed in the stylesheet about 27 different ways, according to all the Qt documentation etc examples.

    So I'm either in need a way 28+ (the most likely by far).

    Or, with just a Qt Script js+ui pair, re hover and pressed events, unsupported ?

    I've not read anything to that effect. But perhaps, you know otherwise..

    Many thanks,


  • Lifetime Qt Champion

    Can it be you have conflicting statements for the pushbuttons ?
    Just tried

      border: 1px solid red;

    and get this
    alt text

  • Hi mrjj,

    Thanks again. Yep, I had tried as above :-/

    But got me thinking. And I realised, my existing styleSheet content, needed the following added, before and after:

    Before: QPushbutton {
    After: }

    Actually, I don't understand why that wrapping is needed, if there are also hover or pressed actions in the styleSheet. Why is that ?

    It also seems a bit odd, telling a QPushButton, it is a QPushButton

    Anyway, with the wrapping added, all is working well :-) #28 it was !

    Many thanks,


  • Lifetime Qt Champion

    Its called a selector.
    We say this is for class type pushbutton. else it would affect all widgets.
    So to avoid a mess, its often good to use a selector.
    Like ClassType, or object name. etc.

  • Ooh ok. Almost all of my styleSheet content is without selectors presently.
    Though oddly, I don't see any other elements getting those styles.

  • Lifetime Qt Champion

    Well it depends on where you set style sheet.
    if directly on widget, then only it self and its children are affected.
    So if directly on button, then you wont see other get the style as they are not
    children. Often you set stylesheet on Mainwindow or application so
    all is covered automatically. and there selectors are important.

Log in to reply