×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Location
    India
    Posts
    123

    Selection Background Color style sheet NO EFFECT

    hi,

    I have designed a Ui using Qt designer In which I have used QPushButton .
    I am setting the style sheet of this button using designer to selection-background-color: rgb(0, 170, 255);

    But the problem is there is no effect of this style on button, only white border appears around it which is very faint.
    So what is the problem,,?? is this a BUG in Qt ??. As i have searched for it but unable to get satisfactory result.
    has anybody got this problem..???

    Regards,
    Vishal.

  2. #2
    Nokia Developer Champion
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    928

    Re: Selection Background Color style sheet NO EFFECT

    hi vishal,

    Have you tried to use the stylesheet in the Qt creator IDE instead of designer?
    I am using the stylesheet in creator IDE and donot face any problem. One more thing regarding the white border around the button may be shown because the focus is set on that button in the form.

    For removing the focus you can use focus policy option.

    hope this might helps you.

    Regards
    Jajal Mehul

  3. #3
    Regular Contributor
    Join Date
    Feb 2009
    Location
    India
    Posts
    123

    Re: Selection Background Color style sheet NO EFFECT

    hi Mehul,

    Thanks for reply ,, I want that focus color to be some another color, than white border .. because as i said it is very faint and when i select another button on that form using navigation key ,its not visible which widget is under focus on that form.

    For ex : suppose on any symbian nokia mobile in my case n72 when we r in menu and want to select some application we navigate using navigation key and we can see background of that icon highlighted. I want that same effect.

    Regards,
    Vishal

  4. #4
    Nokia Developer Champion
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    928

    Re: Selection Background Color style sheet NO EFFECT

    Hi vishal,
    using a focus policy properties of the widget you can set focus to storng.Check the properties in creator or you can set it programatically
    Jajal Mehul

  5. #5
    Regular Contributor
    Join Date
    Feb 2009
    Location
    India
    Posts
    123

    Re: Selection Background Color style sheet NO EFFECT

    Hi Mehul,,

    I have done that change and checked it but on emulator 3rd edition Fp2 it has no effect and on device N95.
    But it shows this border dark white which is visible in E72 so its device dependent ??

    Regards,
    Vishal

  6. #6
    Nokia Developer Champion
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    928

    Re: Selection Background Color style sheet NO EFFECT

    well i had not tried it on device but will check it and tell you...


    Regards
    Jajal Mehul

  7. #7
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Selection Background Color style sheet NO EFFECT

    I remember it was a bug on Symbian style not using stylesheet colors for buttons. Try to run your app with -style=win key or compile it for desktop, to see how it works with other styles.

  8. #8
    Registered User
    Join Date
    Mar 2010
    Posts
    53

    Re: Selection Background Color style sheet NO EFFECT

    Hi !

    use this StyleSheet :

    Code:
    QPushButton::focus {
    	background-color: rgb(0, 0, 0);
    }
    
    QPushButton::!focus {
    	 // other color
    }

  9. #9
    Regular Contributor
    Join Date
    Feb 2009
    Location
    India
    Posts
    123

    Re: Selection Background Color style sheet NO EFFECT

    Quote Originally Posted by Zombieisme View Post
    Hi !

    use this StyleSheet :

    Code:
    QPushButton::focus {
    	background-color: rgb(0, 0, 0);
    }
    
    QPushButton::!focus {
    	 // other color
    }

    Hi Zombieisme

    Thanks for reply ,, I have used above style sheet and whn focus is on that button its color changes to the specified color...
    But the problem still remains see below is the style which i am implementing and it show no effect same light border which is faint...


    QString style;
    style +="QPushButton::focus{border-color: rgb(0, 85, 255);}";
    style +="QPushButton{border-image: url(:/new/prefix1/Images/image.bmp);}";
    style +="QPushButton{border:3px solid green;}";
    style +="QPushButton{ border-radius: 11px;}";
    style +="QPushButton{border-width: 4px;}";

    ui.pushButton->setStyleSheet(style);

    What i want is when there is focus or when we navigate over button using soft keys its border should be highlighted with any specified color ...SO IS THIS POSSIBLE ??? Can we change COLOR OF FOCUS

    Regards,
    Vishal
    Last edited by vishalrocks101; 2010-07-22 at 05:47.

  10. #10
    Registered User
    Join Date
    Mar 2010
    Posts
    53

    Re: Selection Background Color style sheet NO EFFECT

    Sorry, my English is not good so I do not really understand what you want. You may also find this stylesheet:
    Code:
    QPushButton::pressed{border-color: rgb(0, 0, 0);}

  11. #11
    Regular Contributor
    Join Date
    Feb 2009
    Location
    India
    Posts
    123

    Re: Selection Background Color style sheet NO EFFECT

    hi,

    See what i want is ,,,that ,, the focus color to be changed not button color ...

    Because once we place image on button below style has no effect
    QPushButton::focus {
    background-color: rgb(0, 0, 0);
    }

    Only we can see white light border around the button when it is under focus . So is this possible to change this focus color ???

  12. #12
    Registered User
    Join Date
    Mar 2010
    Posts
    53

    Post Re: Selection Background Color style sheet NO EFFECT

    To control the focus rectangle of the button you have implement QWindowsStyle.
    I have not tried to change the color of the focus rectangle but with the code below makes me focus rectangle of the button never appeared. Try to work with it, hope you will find a way to solve your problem.

    Code:
    class NewStyle : public QWindowsStyle
    	{
    public:	
    	void drawControl(ControlElement , const QStyleOption *,
    		QPainter *, const QWidget *  ) const;
           }
    Code:
    void NewStyle::drawControl(ControlElement element, const QStyleOption * option,
    						   QPainter * painter, const QWidget * widget = 0 ) const
    {    
            if(element == CE_PushButton)
            {
            const QStyleOptionButton *b = qstyleoption_cast<const QStyleOptionButton *>(option);
                    QStyleOptionButton *btn = (QStyleOptionButton *)b;
                    if (btn) {
                            if (btn->state & State_HasFocus) {
                                    btn->state = btn->state ^ State_HasFocus;                            
                            }
                    }
                    QWindowsStyle::drawControl(element, btn, painter, widget);
            }
            else
            {
                    QWindowsStyle::drawControl(element, option, painter, widget);
            }
    }
    Code:
    button->setStyle( new NewStyle() );
    Ps: If you succeed, please share your results with everyone.
    Thanks !!
    Last edited by Zombieisme; 2010-07-22 at 13:38.

  13. #13
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Selection Background Color style sheet NO EFFECT

    Rather than change the focus color, why not turn off the focus rectangle and change the border color?

  14. #14
    Regular Contributor
    Join Date
    Feb 2009
    Location
    India
    Posts
    123

    Re: Selection Background Color style sheet NO EFFECT

    Hi danhicksbyron,

    As far as I know Cahnging border color only changes border color and works if button is not having any image .. And Once we place image on Button ie Border Image . Changing border color will have no effect.

    Regards,
    Vishal

Similar Threads

  1. Chage Menupane text color & background color
    By LAS_VEGAS in forum Symbian User Interface
    Replies: 2
    Last Post: 2012-04-13, 12:09
  2. Replies: 0
    Last Post: 2009-04-23, 08:59
  3. Formating color, style appuifw.Text not work
    By adywicaksono in forum Symbian
    Replies: 3
    Last Post: 2006-05-03, 06:39
  4. heading 1 style-sheet problem on 6630
    By mobhaku in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2005-05-20, 14:50
  5. Fade in and out effect on color handsets...
    By Pacess in forum Mobile Java General
    Replies: 1
    Last Post: 2002-06-05, 06:38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×