Results 1 to 1 of 1

Thread: highlight button with dashed line when focus is set by tab

  1. #1
    Join Date
    Jun 2016
    Posts
    99
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default highlight button with dashed line when focus is set by tab

    I want to have a dashed line appear around the current button that has the focus set to it? Like when you tab through fire fox....

    Is there a way to do this?

    Qt Code:
    1. Button {
    2. id: searchBtn
    3. text: qsTr("Search")
    4. action: action_search
    5. opacity: !action.enabled ? .3 : 1.0
    6. KeyNavigation.tab: resetBtn
    7.  
    8. onFocusChanged {
    9. border.color: "yellow"
    10. border.width: 2
    11. }
    12.  
    13. //---Sets button Formatting---//
    14. style: ButtonStyle {
    15. background: Rectangle {
    16. implicitWidth: 90
    17. implicitHeight: 40
    18. anchors.fill:parent
    19. radius: 4
    20. //---Changes butotn color when pressed--//
    21. gradient: Gradient {
    22. GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" }
    23. GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" }
    24. }
    25. //---Sets button Image---//
    26. Image{
    27. width: 24
    28. height: 24
    29. anchors.verticalCenter: parent.verticalCenter
    30. anchors.left: parent.left
    31. anchors.leftMargin: 5
    32. source:"button_ok.png"
    33. }
    34. }
    35. }
    36. }
    To copy to clipboard, switch view to plain text mode 


    update: found a solution:

    Qt Code:
    1. border.color: control.activeFocus ? "yellow" : "#242424"
    2. border.width: control.activeFocus ? 4 : 1
    To copy to clipboard, switch view to plain text mode 
    Last edited by jfinn88; 22nd September 2016 at 21:03. Reason: soln

Similar Threads

  1. Highlight All line in QTextBrowser
    By rz in forum Qt Programming
    Replies: 0
    Last Post: 29th June 2014, 17:38
  2. Disable OS's focus highlight
    By Oleg in forum Qt Programming
    Replies: 1
    Last Post: 19th February 2010, 15:10
  3. Why there are always dashed-line rectangle on QToolButton?
    By FinderCheng in forum Qt Programming
    Replies: 5
    Last Post: 25th October 2009, 00:56
  4. Replies: 0
    Last Post: 13th February 2009, 09:26
  5. Replies: 1
    Last Post: 5th August 2008, 21:44

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.