Results 1 to 1 of 1

Thread: switch position

  1. #1
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default switch position

    Hi,

    Is there a way to modify the groove and handler of switch element to position on the right of the text?

    I am trying to create a custom switch element with text.
    I know this would be possible if i'll put it into RowLayout, however I wanted to use the clicked signal that will be emitted by the Switch that is why i wanted to put it this way.
    I tried using RowLayout and put alias on the Switch however i got stuck in working with the clicked signal of the element.

    Qt Code:
    1. Switch {
    2. id: switch
    3.  
    4. property alias label: label.text
    5.  
    6. style: SwitchStyle {
    7. groove: Rectangle {
    8. id: groove
    9. implicitWidth: 100
    10. implicitHeight: 60
    11. radius: implicitWidth*0.5
    12. color: control.checked ? "green : "white"
    13. border.width: control.checked ? 0 : 1
    14. border.color: "gray"
    15. }
    16. handle: Rectangle {
    17. id: handle
    18. implicitWidth: height
    19. radius: implicitWidth*0.5
    20. color: "white"
    21. border.width: control.checked ? 0 : 1
    22. border.color: "gray"
    23. }
    24. }
    25.  
    26. Text {
    27. id: label
    28.  
    29. horizontalAlignment: Text.AlignLeft
    30. }
    31. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by joko; 26th October 2015 at 10:33.

Similar Threads

  1. Replies: 1
    Last Post: 29th July 2015, 18:10
  2. view position of mouse position in GraphicsScene
    By Raghaw in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2012, 04:46
  3. how to switch from 4.7 to qt 5?
    By saman_artorious in forum Installation and Deployment
    Replies: 5
    Last Post: 10th July 2012, 20:17
  4. Switch blue and red
    By bryan in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 19th January 2010, 15:23
  5. How to switch Qt4 version
    By vieraci in forum Installation and Deployment
    Replies: 1
    Last Post: 1st May 2007, 18:17

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.