Results 1 to 2 of 2

Thread: Removing dotted outline during focus

  1. #1
    Join Date
    Mar 2011
    Posts
    120
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Removing dotted outline during focus

    Hi everyone,
    I am trying to remove the dotted line during focus for QPushButton.

    Qt Code:
    1. QPushButton:focus {outline: 0;}
    To copy to clipboard, switch view to plain text mode 

    This is not working(qt 4.7, windows).
    Can anybody help me ?

    Thanks.

  2. #2
    Join Date
    Mar 2011
    Posts
    120
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Removing dotted outline during focus

    Ok fine. I got it.
    Instead of stylesheet I am using style.
    Check here.

    Qt Code:
    1. class NoFocusProxyStyle : public QProxyStyle
    2. {
    3. public:
    4. NoFocusProxyStyle(QStyle *baseStyle = 0) : QProxyStyle(baseStyle)
    5. {
    6. }
    7.  
    8. void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
    9. QPainter *painter, const QWidget *widget) const
    10. {
    11. if(element == QStyle::PE_FrameFocusRect)
    12. {
    13. return;
    14. }
    15. QProxyStyle::drawPrimitive(element,option,painter,widget);
    16. }
    17.  
    18. };
    To copy to clipboard, switch view to plain text mode 

    [code]
    pushButton->setStyle(new NoFocusProxyStyle());
    [/code

Similar Threads

  1. Replies: 3
    Last Post: 2nd August 2013, 23:53
  2. Doubt with dotted line
    By cesroc in forum Qwt
    Replies: 2
    Last Post: 5th March 2012, 09:30
  3. Removing Focus from QTableWidget
    By kapoorsudhish in forum Newbie
    Replies: 2
    Last Post: 22nd October 2009, 15:16
  4. removing focus of application?
    By triperzonak in forum Qt Programming
    Replies: 0
    Last Post: 16th July 2008, 16:17
  5. QTable, Removing cell focus
    By Kubil in forum Qt Programming
    Replies: 2
    Last Post: 27th July 2007, 11:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.