Results 1 to 3 of 3

Thread: Change properties of delegates in ListView

  1. #1
    Join Date
    Jun 2013
    Posts
    2
    Qt products
    Qt4 Qt5

    Default Change properties of delegates in ListView

    Hello everyone,

    even though I am quite new in this community, I hope that someone can help me with a huge problem for me.

    I am trying to change the opacity of a delegate, but I have no idea how to adress it.

    How can I change the opacity of a certain delegate, when I click the MouseArea?

    Thanks for the help!


    The Fraction:
    Qt Code:
    1. ListView {
    2. id: imageList
    3.  
    4. property int selection: 0
    5.  
    6. anchors.centerIn: parent
    7. width: 75
    8. height: 500
    9. spacing: 80
    10.  
    11. FolderListModel {
    12. id: imageFolderModel
    13. showDirs: true
    14. folder: "/opt/org.seadot.desktop/qml/Apps/"
    15. nameFilters: [ "*.svg" ]
    16. }
    17.  
    18. Component {
    19. id: imageFileDelegate
    20.  
    21. Item {
    22. Image{
    23. id: launcherItem
    24. width: 75
    25. height: 75
    26. sourceSize.width: 75
    27. sourceSize.height: 75
    28. source: "file:///opt/org.seadot.desktop/qml/Apps/"+fileName+"/icon.svg"
    29.  
    30. MouseArea {
    31. anchors.fill: parent
    32.  
    33. onClicked: {
    34. imageList.selection = index;
    35. imageList.model.opacity = 0.5
    36. }
    37. }
    38. }
    39. }
    40. }
    41.  
    42. model: imageFolderModel
    43. delegate: imageFileDelegate
    44. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    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: Change properties of delegates in ListView

    Add a property in ListView and refer to that property from within the delegate.

    javascript Code:
    1. ListView {
    2. id: lv
    3. property real delegateOpacity: 0.5
    4.  
    5. model: ...
    6.  
    7. delegate: Rectangle {
    8. opacity: delegateOpacity
    9. // ...
    10. }
    11. }
    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.


  3. #3
    Join Date
    Jun 2013
    Posts
    2
    Qt products
    Qt4 Qt5

    Default Re: Change properties of delegates in ListView

    Thanks, that was the solution!

    Really appreciate it!

Similar Threads

  1. Replies: 1
    Last Post: 28th June 2012, 16:32
  2. Replies: 1
    Last Post: 23rd June 2012, 13:23
  3. Replies: 0
    Last Post: 14th June 2011, 16:02
  4. Replies: 0
    Last Post: 22nd May 2011, 08:42
  5. How is it easier to change font properties?
    By alex chpenst in forum Qt Programming
    Replies: 1
    Last Post: 11th July 2008, 20:01

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.