Results 1 to 20 of 25

Thread: slider control

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default slider control

    Hello forum,

    I am trying to render a qml slider on top of the translucent rectangle as follows:

    Qt Code:
    1. Rectangle {
    2. id: rect
    3. width: parent.width/2; height: parent.height/5
    4. color: "red"
    5. radius: 10
    6. opacity: 0.1
    7. border.color: "black"
    8.  
    9.  
    10. Slider {
    11. id: outerTessellationSlider
    12. activeFocusOnPress: true
    13. minimumValue: 1.0
    14. maximumValue: 64.0
    15. stepSize: 1.0
    16. tickmarksEnabled: true
    17.  
    18. }
    19.  
    20. }
    To copy to clipboard, switch view to plain text mode 

    As you can see i have define quite a few properties for the slider, but none of them seems to be in effect. I have enabled the tick marks , but it is not visible. I have set the minimum and maximum value , but slider remains in the same size. What may be the reason behind this ?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: slider control

    Your slider does not have any width or height set and is not resized by a layout or anchors either.

    tick marks might be style dependent or not visible in your case because you only have an opacity value of 0.1

    Cheers,
    _

  3. #3
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: slider control

    is it possible to override some of the properties in parent. The opacity value for the rectangle is set to 0.1. Will this value be over-ridden if I set the opacity to some thing else ? I tried and it is not working.

    Any hint ?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: slider control

    Opacity, like transformation properties (scale, rotation) apply to the whole sub tree starting at the element that has them.

    Basically the respective properties of the children are relative to the parent.

    If you want a full opaque slider on a partly transparent rectangle do not make the silder a child of the rectangle.

    E.g. make them siblings

    Cheers,
    _

  5. #5
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: slider control

    can you refer me to any example code to get hint from ?

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: slider control

    Qt Code:
    1. Item {
    2. Rectangle {
    3. opacity: 0.1
    4. }
    5. Slider {
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  7. #7
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: slider control

    Quote Originally Posted by anda_skoa View Post
    Your slider does not have any width or height set and is not resized by a layout or anchors either.
    The width and height property are not even defined , as I looked up in the documentaion.

    I am using Qt 5.2 with QtQuick.Controls 1.1.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: slider control

    Quote Originally Posted by sajis997 View Post
    The width and height property are not even defined
    Width and height properties are defined in Item element type which the slider is a descendent of.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: slider control

    I better explain more over the issues of designing the user interface. I have already had the opengl scene as an underlay and i am trying to have the UI grouped into a translucent (opacity : 0.1) and rounded rectangle.

    I want to have two sliders along with two text items well-aligned in a grid-layout and stuffed inside the translucent rectangle. Initially i had all the items inside the rectangle and i found that the transparentcy that is applied to the rectangle is also applied to all the of the children. This is not what i wanted. Then i was suggested that i should put the items(Text, and Slider) as siblings instead of children. Now how should I align the grid layout with the rectangle so that it moves along with the rectangle ?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: slider control

    Quote Originally Posted by sajis997 View Post
    Now how should I align the grid layout with the rectangle so that it moves along with the rectangle ?
    Exactly the same way as you did before. Just instead of wrapping your items in a semi-transparent rectangle, wrap them in an invisible item and make that item sibling of the rectangle and make it same size as the rectangle.

    javascript Code:
    1. Rectangle {
    2. id: background
    3.  
    4. opacity: 0.1
    5. radius: 20
    6. border { width: 1; color: "black" }
    7. color: "gray"
    8. anchors.fill: controlLayout
    9. }
    10.  
    11. GridLayout {
    12. id: controlLayout
    13.  
    14. columns: 2
    15. Text { "Slider1:" }
    16. Slider { ... }
    17. Text { "Slider2:" }
    18. Slider { ... }
    19. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. The following user says thank you to wysota for this useful post:

    sajis997 (30th December 2014)

  12. #11
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: slider control

    HelLo Forum,

    I am trying to relocate the rectange with the following command :

    Qt Code:
    1. Rectangle {
    2. id: rect
    3. x: -100
    4. color: "red"
    5. radius: 10
    6. opacity: 0.1
    7. border.color: "black"
    8. anchors.fill: controlLayout
    9. }
    To copy to clipboard, switch view to plain text mode 

    But the rectange is not moving at all, it is pinned at the left corder of the window. Here goes the contents of the whole .qml file.

    Qt Code:
    1. import QtQuick 2.0
    2. import QtQuick.Controls 1.1
    3. import QtQuick.Layouts 1.1
    4. import TeapotTessellation 1.0
    5.  
    6. Item {
    7. id: root
    8. width: 512; height: 512
    9.  
    10. Text {
    11. text: "F1 - Show/Hide Settings"
    12. font.pixelSize: 15
    13. anchors.top: parent.top
    14. anchors.topMargin: 15
    15. anchors.right: parent.right
    16. anchors.rightMargin: 15
    17. opacity: 0.5
    18. }
    19.  
    20. TessellationSceneItem
    21. {
    22. id: tessSceneItem
    23. }
    24.  
    25. GridLayout {
    26. id: controlLayout
    27. columns: 2
    28.  
    29. Text {
    30. id: outerTessellationText
    31. text: qsTr("Outer Tessellation Factor: ")
    32. color: "black"
    33. opacity: 1.0
    34. }
    35.  
    36. Slider {
    37. id: outerTessellationSlider
    38. opacity: 1.0
    39. minimumValue: 1.0
    40. maximumValue: tessSceneItem.maxTessLevel
    41. stepSize: 1.0
    42. Layout.fillWidth: true
    43.  
    44. onValueChanged: tessSceneItem.outer = value
    45. }
    46.  
    47.  
    48. Text {
    49. id: innerTessellationText
    50. text: qsTr("Inner Tessellation Factor: ")
    51. color: "black"
    52. opacity: 1.0
    53. }
    54.  
    55.  
    56.  
    57. Slider {
    58. id: innerTessellationSlider
    59. opacity: 1.0
    60.  
    61. minimumValue: 1.0
    62. maximumValue: tessSceneItem.maxTessLevel
    63. stepSize: 1.0
    64. Layout.fillWidth: true
    65.  
    66. onValueChanged: tessSceneItem.inner = value
    67. }
    68. }
    69.  
    70.  
    71. Rectangle {
    72. id: rect
    73. x: -120
    74. color: "red"
    75. radius: 10
    76. opacity: 0.1
    77. border.color: "black"
    78. anchors.fill: controlLayout
    79.  
    80. }
    81.  
    82. }
    To copy to clipboard, switch view to plain text mode 

  13. #12
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: slider control

    The rectangle has "anchors.fill", it will fill the given reference element.

    Btw, your onValueChanged handlers could be replaced by property bindings on the target element.

    Cheers,
    _

  14. #13
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: slider control

    Quote Originally Posted by anda_skoa View Post
    The rectangle has "anchors.fill", it will fill the given reference element.
    Did you mean that the rectangle and the controlLayout will have the same geometry ? I believe it is as mentioned in the documentation.

    Is this the reason that the rectangle is not moving even after the attempt of relocation ?

    Quote Originally Posted by anda_skoa View Post
    Btw, your onValueChanged handlers could be replaced by property bindings on the target element.
    Is this the suggestion for improvement or the reason behind the issue I am trying to address ?

    Thanks

    Cheers,

  15. #14
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: slider control

    Quote Originally Posted by sajis997 View Post
    Did you mean that the rectangle and the controlLayout will have the same geometry ?
    Yes

    Quote Originally Posted by sajis997 View Post
    Is this the reason that the rectangle is not moving even after the attempt of relocation ?
    Yes.

    "Filling" is a pretty clear instructions, it tells the element to have exactly the same geometry as the other one.

    This is not a Schrödinger experiement
    The rectangle can either fill the reference element or it can not.
    If you tell it to fill, then you've made your choice.


    Quote Originally Posted by sajis997 View Post
    Is this the suggestion for improvement or the reason behind the issue I am trying to address ?
    Suggestion for improvement, unrelated to this.

    Cheers,
    _

  16. #15
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: slider control

    Let me re-iterate my goal here. I am trying to use the springanimation over the rectangle that in turn contains the several elements in grid layout. As you mentioned in your previous post that the reason behind that the rectangle is not moving is :


    Qt Code:
    1. anchors.fill = <id To the gridlayout>
    To copy to clipboard, switch view to plain text mode 

    Do you have any hint to achieve this small goal - bring in the UI elements arranged in grid layout by spring animation ?

    Thanks

  17. #16
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: slider control

    Quote Originally Posted by sajis997 View Post
    Now how should I align the grid layout with the rectangle so that it moves along with the rectangle ?
    Or you don't do that, have both children anchored to the parent and move the parent.

    Cheers,
    _

Similar Threads

  1. Replies: 3
    Last Post: 29th July 2014, 18:18
  2. Dynamic label to right of slider resizes slider
    By zenzero-2001 in forum Qt Programming
    Replies: 2
    Last Post: 3rd October 2013, 10:11
  3. Replies: 4
    Last Post: 3rd August 2010, 12:30
  4. Replies: 2
    Last Post: 21st March 2010, 09:01
  5. slider control and combo box in grid view
    By steg90 in forum Qt Programming
    Replies: 13
    Last Post: 21st November 2007, 10:45

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.