Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to show and hide image on tableview column header selection



  • Eg : Image is part of header delegate
    Image {
    id:arrowimgid
    Layout.alignment: Qt.AlignVCenter
    Layout.topMargin: dp(15)
    source: (styleData.column === 1 || styleData.column === 2 || styleData.column === 3
    || styleData.column === 4 || styleData.column === 5 || styleData.column === 6 || styleData.column === 7) ? "images/down-arrow.png" : ""
    opacity: DCMGlobal.roleacces === 0 ? 1.0 : 0.5
    visible: (styleData.column === 1) ? true : false
    }

    As part of connections property doing below things
    Connections {
    target: styleData
    onPressedChanged: {

                                    if(styleData.column === 1 && isSorted === true) {
    
                                        if(tableViewId.sortIndicatorOrder === 0) {
                                            arrowimgid.visible = true
                                            arrowimgid.source = "images/up-arrow.png"
                                        }
                                        else if(tableViewId.sortIndicatorOrder === 1) {
    
                                            arrowimgid.source = "images/down-arrow.png"
                                        }
                                    }
    
                                    if(styleData.column === 2 && isSorted === true) {
    
                                        if(tableViewId.sortIndicatorOrder === 0) {
                                            arrowimgid.visible = true
                                            arrowimgid.source = "images/up-arrow.png"
                                        }
                                        else if(tableViewId.sortIndicatorOrder === 1) {
    
                                            arrowimgid.source = "images/down-arrow.png"
                                        }
                                    }
    
                                    if(styleData.column === 3 && isSorted === true) {
    
                                        if(tableViewId.sortIndicatorOrder === 0) {
                                            arrowimgid.visible = true
                                            arrowimgid.source = "images/up-arrow.png"
                                        }
                                        else if(tableViewId.sortIndicatorOrder === 1) {
    
                                            arrowimgid.source = "images/down-arrow.png"
                                        }
                                    }
    

    }

    Please suggest how to show image on based on selected header and hide image on other columns.



  • This post is deleted!

Log in to reply