Unsolved Getting compilation errors
-
class myQtreeWidget : public QTreeWidget {
public:
myQtreeWidget() {};
int rowHeight(QModelIndex& index) { return QTreeView::rowHeight(index);}};
myQtreeWidget* treeWidget = new myQtreeWidget();
QModelIndex index = treeWidget->indexAt(QPoint(0,0));
int h = treeWidget->height();int noOfRows = treeWidget->height()/treeWidget->rowHeight(index);
Please help me correcting the compilation errors
-
@Qt-Enthusiast said in Getting compilation errors:
Please help me correcting the compilation errors
Which error?
-
Hi,
rowHeight
is a const method and more important it's not virtual. -
how to get rowHeigt of first row in QtreeWidget
-
@Qt-Enthusiast
https://doc.qt.io/qt-5/qtreeview.html#rowHeightint QTreeView::rowHeight(const QModelIndex &index) const
[protected]
Returns the height of the row indicated by the given index.
So pass it the
QModelIndex
of a cell in the first row.Note that this is a
protected
function. This means you will only be able to access if you derive your own class fromQTableWidget
, not if you just use that directly.If that is not convenient for you, you might use
QRect QTreeView::visualRect(const QModelIndex &index) const
(https://doc.qt.io/qt-5/qtreeview.html#visualRect) instead. This also would indicate whether an item is visible or not, which I think you asked about in another similar post.