Results 1 to 9 of 9

Thread: How can i avoid QPushButton Focus Rectangle

  1. #1
    Join Date
    Sep 2010
    Posts
    46
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question How can i avoid QPushButton Focus Rectangle

    Hi there,

    I have a trouble with annoying Focus Rectangle on Windows, I found http://developer.qt.nokia.com/faq/an..._on_my_buttons that link for avoid Focus Rect on Buttons but it's not working for me actually. I'm using arrow keys for navigate on the form elements like buttons but when focused a button there is appearing a rectangle on button , someone have an idea for this problem. Thx ...

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can i avoid QPushButton Focus Rectangle

    You'll need to draw the control yourself then, but the idea of the focus rect to make navigating your application without the mouse easier.

  3. #3
    Join Date
    Sep 2010
    Posts
    46
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How can i avoid QPushButton Focus Rectangle

    Quote Originally Posted by squidge View Post
    You'll need to draw the control yourself then, but the idea of the focus rect to make navigating your application without the mouse easier.
    Well thx for answer but could you give me piece of code about drawing control myself. By the way i'm using Stylesheets for focus event i'm highlighting buttons with setting new backcolor. So there ll be no mouse in my application also Focus rect is looking so ugly in my interface ...

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How can i avoid QPushButton Focus Rectangle

    As already noted, if you're going to build your own interface, you'll have to...build your own interface. By drawing it from scratch. There are plenty of tutorials in the Qt documentation that can guide you.

    However, note that this generally isn't a good idea. People get used to their native interface, and get disturbed when it stops working the way it usually does. It's better to focus your energies on ensuring that what your program actually does, it does well, and leave the user interface issues to the operating system.

  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can i avoid QPushButton Focus Rectangle

    Quote Originally Posted by nightroad View Post
    Well thx for answer but could you give me piece of code about drawing control myself.
    You can subclass whatever controls you need to draw your self, and well, you have the ultimate source code - the code to the Qt library itself, so you can see exactly how it does it. Plus, there is lots of examples in the distribution too.

  6. #6
    Join Date
    Sep 2010
    Posts
    46
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Lightbulb Re: How can i avoid QPushButton Focus Rectangle

    Quote Originally Posted by SixDegrees View Post
    if you're going to build your own interface, you'll have to...build your own interface.
    lol thx for good explanation (; ...

    Quote Originally Posted by SixDegrees View Post
    It's better to focus your energies on ensuring that what your program actually does,
    Tbh, my program working well, atm i have to make a good user experience as i said i'll hide mouse pointer on the application so i have to navigate buttons with arrow keys there is just a problem for me atm annoying focus rect ...

    Anyway Thanks for help. i'm new on qt and i'm gonna digging it ...

  7. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How can i avoid QPushButton Focus Rectangle

    search the forum. This is a question coming up very often. Mostly for graphics view, but you can use it for normal widgets as well. No custom painting is needed. Just remove the hasfocus flag before redirecting to to the original paint method.

  8. #8
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can i avoid QPushButton Focus Rectangle

    The link in the first post uses the hasfocus flag, but the OP stated that this didn't work for him, so the only other suggestion is custom painting, surely?

  9. #9
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How can i avoid QPushButton Focus Rectangle

    Quote Originally Posted by squidge View Post
    The link in the first post uses the hasfocus flag, but the OP stated that this didn't work for him
    Yes, true, but then he should say what does not work for him, because it works. Also a possibility is to subclass QPushButton direct instead of using a style. (Even better would be a proxystyle.)

Similar Threads

  1. Replies: 13
    Last Post: 24th August 2018, 14:29
  2. Prevent QStyledItemDelegate from drawing focus rectangle
    By stefanadelbert in forum Qt Programming
    Replies: 4
    Last Post: 15th July 2010, 09:43
  3. Hide the focus rectangle of a QGraphicsLineItem
    By ronno in forum Qt Programming
    Replies: 2
    Last Post: 16th June 2009, 10:47
  4. Preventing blue focus rectangle
    By MrGarbage in forum Qt Programming
    Replies: 2
    Last Post: 21st December 2007, 15:36
  5. Replies: 3
    Last Post: 26th September 2006, 12:16

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.