Results 1 to 2 of 2

Thread: How to highlight a QWidget

  1. #1
    Join Date
    May 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default How to highlight a QWidget

    Hello everyone! Here is my question:

    I've derived the QToolButton so that buttons in QToolBar can be accessed by tabbing, but when it gains focus it is not highlighted like when i hover with the cursor over it. I've overriden the focusInEvent function, but when it comes to actually highlighting the button I don't know what property/attribute to set or what method to call.

    Here is what it looks like when I hover with the cursor over the button:
    example1.png
    How can I achieve this by replacing the line marked?

    Here is what is currently happening:
    example2.png

    Qt Code:
    1. void focusInEvent(QFocusEvent* e){
    2. if(e->gotFocus() && e->reason() == Qt::TabFocusReason){
    3. setGraphicsEffect(new QGraphicsColorizeEffect()); //line to be replaced
    4. }
    5. QToolButton::focusInEvent(e);
    6. }
    To copy to clipboard, switch view to plain text mode 

    Thank you for your help!

  2. #2
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to highlight a QWidget

    Try style sheet for the widget focus, see below style sheet example for QWidget focus...

    QWidget:focus {border: 3px solid green;}

Similar Threads

  1. How to Highlight a PixMap?
    By LaTj in forum Newbie
    Replies: 2
    Last Post: 5th November 2013, 00:23
  2. Highlight the text in QWidget on mouseMoveEvent
    By mythili in forum Qt Programming
    Replies: 6
    Last Post: 24th April 2013, 09:43
  3. Highlight of an ListView
    By Gihu in forum Qt Quick
    Replies: 1
    Last Post: 2nd July 2012, 18:13
  4. highlight problem
    By supriyajn in forum Newbie
    Replies: 1
    Last Post: 20th May 2010, 20:00
  5. highlight in QTextEdit
    By ubuntudevelop78 in forum Qt Programming
    Replies: 1
    Last Post: 27th November 2009, 01:22

Tags for this Thread

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.