Unsolved How can I add horizontal scroll bar for specific columns in QML table view component?
-
How can I add horizontal scroll bar in qml table view for specific columns ? (e.g. I need horizontal scroll bar from column 3 to column 7 and I have total 11 columns in my table view). I have already implemented customize columns using delegate chooser component with the help of adding roles in C++ QAbstractTableModel Class.
-
@shawnrutledge can you please help me in this implementation? I am seeking for any idea or hint to implement this
-
property bool enableScrollbar: column >= 3 && column <= 7
Use this boolean to enable scrollbar for that cell.
-
@fcarney said in How can I add horizontal scroll bar for specific columns in QML table view component?:
enable
Where and how can I apply this property to QML table view ?
-
@sudarshand said in How can I add horizontal scroll bar for specific columns in QML table view component?:
Where and how can I apply this property to QML table view ?
-
@fcarney I am not able to achieve what I want from these inputs...., I am not able to apply this in my QML table view implementation.
-
Create a minimal example code for us to look at. I cannot tell what you are doing.
-
This post is deleted! -
Hello @fcarney please refer following QML implementation , tableviewmodel is my C++ model inherited from QAbstractTableModel class having 11 columns and some rows. I want horizontal scrolling for column 3 to 7 only and all other columns should be freeze.
Because of this line i.e. ScrollBar.horizontal: ScrollBar{} , I am getting horizontal scroll bar for all the columns.TableView {
id: tableview
anchors.fill: parent
columnSpacing: 1
rowSpacing: 1
columnWidthProvider: function(col) {
if( 0 === col || 1 === col || 10 === col)
return 40
else if(3 === col)
return 80
else
return 60
}
rowHeightProvider: function(){
return 60
}
clip: true
ScrollBar.horizontal: ScrollBar{}
ScrollBar.vertical: ScrollBar{}
model: tableviewmodeldelegate: Rectangle { Text { text: roletabledata } }
}
-
@fcarney said in How can I add horizontal scroll bar for specific columns in QML table view component?:
property bool enableScrollbar: column >= 3 && column <= 7
TableView { id: tableview property bool enableScrollbar: column >= 3 && column <= 7 ... ScrollBar.horizontal: ScrollBar{ visible: tableview.enableScrollbar // not sure if you need to use enable or not } }
-
@fcarney said in How can I add horizontal scroll bar for specific columns in QML table view component?:
ScrollBar.horizontal: ScrollBar{
visible: tableview.enableScrollbar // not sure if you need to use enable or not
}Alternately:
ScrollBar.horizontal: tableview.enableScrollbar ? ScrollBar{} : null
-
@fcarney for this its giving QML error that column is not defined.
-
Sorry, this should be inside the delegate:
TableView { id: tableview property bool enableScrollbar: column >= 3 && column <= 7 ... ScrollBar.horizontal: ScrollBar{ visible: tableview.enableScrollbar // not sure if you need to use enable or not } } A reference a day helps keep the segfault away. 0 fcarney about 24 hours ago @fcarney said in How can I add horizontal scroll bar for specific columns in QML table view component?: ScrollBar.horizontal: ScrollBar{ visible: tableview.enableScrollbar // not sure if you need to use enable or not } Alternately: ScrollBar.horizontal: tableview.enableScrollbar ? ScrollBar{} : null A reference a day helps keep the segfault away. 0 sudarshand about 9 hours ago @fcarney for this its giving QML error that column is not defined. 0 12 Posts 84 Views @fcarney said in How can I add horizontal scroll bar for specific columns in QML table view component?: property bool enableScrollbar: column >= 3 && column <= 7 TableView { id: tableview delegate: Flickable { // some kind of flickable I think property bool enableScrollbar: column >= 3 && column <= 7 ScrollBar.horizontal: ScrollBar{ visible: tableview.enableScrollbar // not sure if you need to use enable or not } } }
Rectangle is not a flickable I don't think. I don't know if it will work with that.
Spend more time reading the docs. -
I am able to achieve it, using QML vertical header view component of Qt version 5.15.4.