Using Hover and Pressed stylesheet Qt










12















I used this in my button pushButton stylesheet



 QPushButton#pushButton 
background-color: yellow;

QPushButton#pushButton:pressed
background-color: rgb(224, 0, 0);

QPushButton#pushButton:hover
background-color: rgb(224, 255, 0);



when I hover my mouse over it, it changes color, like I expect it to , But the hover color remains even when I press the button.
I tried changing the order, but its still the same problem .
little new in Qt.










share|improve this question



















  • 2





    'pusButton'. Eeew!

    – Michael Scheper
    Aug 3 '16 at 21:33















12















I used this in my button pushButton stylesheet



 QPushButton#pushButton 
background-color: yellow;

QPushButton#pushButton:pressed
background-color: rgb(224, 0, 0);

QPushButton#pushButton:hover
background-color: rgb(224, 255, 0);



when I hover my mouse over it, it changes color, like I expect it to , But the hover color remains even when I press the button.
I tried changing the order, but its still the same problem .
little new in Qt.










share|improve this question



















  • 2





    'pusButton'. Eeew!

    – Michael Scheper
    Aug 3 '16 at 21:33













12












12








12


5






I used this in my button pushButton stylesheet



 QPushButton#pushButton 
background-color: yellow;

QPushButton#pushButton:pressed
background-color: rgb(224, 0, 0);

QPushButton#pushButton:hover
background-color: rgb(224, 255, 0);



when I hover my mouse over it, it changes color, like I expect it to , But the hover color remains even when I press the button.
I tried changing the order, but its still the same problem .
little new in Qt.










share|improve this question
















I used this in my button pushButton stylesheet



 QPushButton#pushButton 
background-color: yellow;

QPushButton#pushButton:pressed
background-color: rgb(224, 0, 0);

QPushButton#pushButton:hover
background-color: rgb(224, 255, 0);



when I hover my mouse over it, it changes color, like I expect it to , But the hover color remains even when I press the button.
I tried changing the order, but its still the same problem .
little new in Qt.







qt hover stylesheet rollover






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 29 '16 at 18:45









mitjap

1381312




1381312










asked Oct 3 '13 at 13:54









harveyslashharveyslash

3,12363778




3,12363778







  • 2





    'pusButton'. Eeew!

    – Michael Scheper
    Aug 3 '16 at 21:33












  • 2





    'pusButton'. Eeew!

    – Michael Scheper
    Aug 3 '16 at 21:33







2




2





'pusButton'. Eeew!

– Michael Scheper
Aug 3 '16 at 21:33





'pusButton'. Eeew!

– Michael Scheper
Aug 3 '16 at 21:33












3 Answers
3






active

oldest

votes


















27














You can combine states, for example:



QPushButton:hover:!pressed

border: 1px solid red;



QSS reference - states






share|improve this answer

























  • okay ! works fine. thanks a lot I used this :: QPushButton#pushButton background-color:red QPushButton#pushButton:hover:!pressed background-color:green QPushButton#pushButton:hover background-color:yellow

    – harveyslash
    Oct 3 '13 at 14:42












  • It is an answer to your question, but in one line. I'll adjust it, if you don't understand ;). Main idea, that you can combine states as you wish. I propose to read qt documentation, there are a lot of useful samples - doc.qt.digia.com/4.7/stylesheet-reference.html

    – Dmitry Sazonov
    Oct 3 '13 at 14:43



















2














Css, and Qt CSS, depends on the order of declarations. Later declarations with the same specificity will overwrite previous declarations. So, in order to have the pressed state take precedence, simply move it below the hover state.



QPushButton#pushButton 
background-color: yellow;


QPushButton#pushButton:hover
background-color: rgb(224, 255, 0);


QPushButton#pushButton:pressed
background-color: rgb(224, 0, 0);






share|improve this answer






























    -2














    You can set the image in QPushButton:



    QPushButton#pushButton 
    background-url(Images/image1.png);

    QPushButton#pushButton:pressed
    background-url(Images/image2.png);


    QPushButton#pushButton:hover
    background-url(Images/image3.png);






    share|improve this answer


















    • 10





      Why did you think the question was about background images?

      – Michael Scheper
      Aug 17 '16 at 16:00










    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19161119%2fusing-hover-and-pressed-stylesheet-qt%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    27














    You can combine states, for example:



    QPushButton:hover:!pressed

    border: 1px solid red;



    QSS reference - states






    share|improve this answer

























    • okay ! works fine. thanks a lot I used this :: QPushButton#pushButton background-color:red QPushButton#pushButton:hover:!pressed background-color:green QPushButton#pushButton:hover background-color:yellow

      – harveyslash
      Oct 3 '13 at 14:42












    • It is an answer to your question, but in one line. I'll adjust it, if you don't understand ;). Main idea, that you can combine states as you wish. I propose to read qt documentation, there are a lot of useful samples - doc.qt.digia.com/4.7/stylesheet-reference.html

      – Dmitry Sazonov
      Oct 3 '13 at 14:43
















    27














    You can combine states, for example:



    QPushButton:hover:!pressed

    border: 1px solid red;



    QSS reference - states






    share|improve this answer

























    • okay ! works fine. thanks a lot I used this :: QPushButton#pushButton background-color:red QPushButton#pushButton:hover:!pressed background-color:green QPushButton#pushButton:hover background-color:yellow

      – harveyslash
      Oct 3 '13 at 14:42












    • It is an answer to your question, but in one line. I'll adjust it, if you don't understand ;). Main idea, that you can combine states as you wish. I propose to read qt documentation, there are a lot of useful samples - doc.qt.digia.com/4.7/stylesheet-reference.html

      – Dmitry Sazonov
      Oct 3 '13 at 14:43














    27












    27








    27







    You can combine states, for example:



    QPushButton:hover:!pressed

    border: 1px solid red;



    QSS reference - states






    share|improve this answer















    You can combine states, for example:



    QPushButton:hover:!pressed

    border: 1px solid red;



    QSS reference - states







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Sep 26 '18 at 11:49

























    answered Oct 3 '13 at 14:41









    Dmitry SazonovDmitry Sazonov

    6,96512354




    6,96512354












    • okay ! works fine. thanks a lot I used this :: QPushButton#pushButton background-color:red QPushButton#pushButton:hover:!pressed background-color:green QPushButton#pushButton:hover background-color:yellow

      – harveyslash
      Oct 3 '13 at 14:42












    • It is an answer to your question, but in one line. I'll adjust it, if you don't understand ;). Main idea, that you can combine states as you wish. I propose to read qt documentation, there are a lot of useful samples - doc.qt.digia.com/4.7/stylesheet-reference.html

      – Dmitry Sazonov
      Oct 3 '13 at 14:43


















    • okay ! works fine. thanks a lot I used this :: QPushButton#pushButton background-color:red QPushButton#pushButton:hover:!pressed background-color:green QPushButton#pushButton:hover background-color:yellow

      – harveyslash
      Oct 3 '13 at 14:42












    • It is an answer to your question, but in one line. I'll adjust it, if you don't understand ;). Main idea, that you can combine states as you wish. I propose to read qt documentation, there are a lot of useful samples - doc.qt.digia.com/4.7/stylesheet-reference.html

      – Dmitry Sazonov
      Oct 3 '13 at 14:43

















    okay ! works fine. thanks a lot I used this :: QPushButton#pushButton background-color:red QPushButton#pushButton:hover:!pressed background-color:green QPushButton#pushButton:hover background-color:yellow

    – harveyslash
    Oct 3 '13 at 14:42






    okay ! works fine. thanks a lot I used this :: QPushButton#pushButton background-color:red QPushButton#pushButton:hover:!pressed background-color:green QPushButton#pushButton:hover background-color:yellow

    – harveyslash
    Oct 3 '13 at 14:42














    It is an answer to your question, but in one line. I'll adjust it, if you don't understand ;). Main idea, that you can combine states as you wish. I propose to read qt documentation, there are a lot of useful samples - doc.qt.digia.com/4.7/stylesheet-reference.html

    – Dmitry Sazonov
    Oct 3 '13 at 14:43






    It is an answer to your question, but in one line. I'll adjust it, if you don't understand ;). Main idea, that you can combine states as you wish. I propose to read qt documentation, there are a lot of useful samples - doc.qt.digia.com/4.7/stylesheet-reference.html

    – Dmitry Sazonov
    Oct 3 '13 at 14:43














    2














    Css, and Qt CSS, depends on the order of declarations. Later declarations with the same specificity will overwrite previous declarations. So, in order to have the pressed state take precedence, simply move it below the hover state.



    QPushButton#pushButton 
    background-color: yellow;


    QPushButton#pushButton:hover
    background-color: rgb(224, 255, 0);


    QPushButton#pushButton:pressed
    background-color: rgb(224, 0, 0);






    share|improve this answer



























      2














      Css, and Qt CSS, depends on the order of declarations. Later declarations with the same specificity will overwrite previous declarations. So, in order to have the pressed state take precedence, simply move it below the hover state.



      QPushButton#pushButton 
      background-color: yellow;


      QPushButton#pushButton:hover
      background-color: rgb(224, 255, 0);


      QPushButton#pushButton:pressed
      background-color: rgb(224, 0, 0);






      share|improve this answer

























        2












        2








        2







        Css, and Qt CSS, depends on the order of declarations. Later declarations with the same specificity will overwrite previous declarations. So, in order to have the pressed state take precedence, simply move it below the hover state.



        QPushButton#pushButton 
        background-color: yellow;


        QPushButton#pushButton:hover
        background-color: rgb(224, 255, 0);


        QPushButton#pushButton:pressed
        background-color: rgb(224, 0, 0);






        share|improve this answer













        Css, and Qt CSS, depends on the order of declarations. Later declarations with the same specificity will overwrite previous declarations. So, in order to have the pressed state take precedence, simply move it below the hover state.



        QPushButton#pushButton 
        background-color: yellow;


        QPushButton#pushButton:hover
        background-color: rgb(224, 255, 0);


        QPushButton#pushButton:pressed
        background-color: rgb(224, 0, 0);







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 10 '17 at 13:37









        mflodinmflodin

        551520




        551520





















            -2














            You can set the image in QPushButton:



            QPushButton#pushButton 
            background-url(Images/image1.png);

            QPushButton#pushButton:pressed
            background-url(Images/image2.png);


            QPushButton#pushButton:hover
            background-url(Images/image3.png);






            share|improve this answer


















            • 10





              Why did you think the question was about background images?

              – Michael Scheper
              Aug 17 '16 at 16:00















            -2














            You can set the image in QPushButton:



            QPushButton#pushButton 
            background-url(Images/image1.png);

            QPushButton#pushButton:pressed
            background-url(Images/image2.png);


            QPushButton#pushButton:hover
            background-url(Images/image3.png);






            share|improve this answer


















            • 10





              Why did you think the question was about background images?

              – Michael Scheper
              Aug 17 '16 at 16:00













            -2












            -2








            -2







            You can set the image in QPushButton:



            QPushButton#pushButton 
            background-url(Images/image1.png);

            QPushButton#pushButton:pressed
            background-url(Images/image2.png);


            QPushButton#pushButton:hover
            background-url(Images/image3.png);






            share|improve this answer













            You can set the image in QPushButton:



            QPushButton#pushButton 
            background-url(Images/image1.png);

            QPushButton#pushButton:pressed
            background-url(Images/image2.png);


            QPushButton#pushButton:hover
            background-url(Images/image3.png);







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Dec 4 '15 at 9:03









            Bhaskar Kumar SinghBhaskar Kumar Singh

            15525




            15525







            • 10





              Why did you think the question was about background images?

              – Michael Scheper
              Aug 17 '16 at 16:00












            • 10





              Why did you think the question was about background images?

              – Michael Scheper
              Aug 17 '16 at 16:00







            10




            10





            Why did you think the question was about background images?

            – Michael Scheper
            Aug 17 '16 at 16:00





            Why did you think the question was about background images?

            – Michael Scheper
            Aug 17 '16 at 16:00

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19161119%2fusing-hover-and-pressed-stylesheet-qt%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            ReactJS Fetched API data displays live - need Data displayed static

            Evgeni Malkin