Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Getting compilation errors
Forum Updated to NodeBB v4.3 + New Features

Getting compilation errors

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 492 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by Qt Enthusiast
    #1

    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

    aha_1980A 1 Reply Last reply
    0
    • Q Qt Enthusiast

      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

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Qt-Enthusiast said in Getting compilation errors:

      Please help me correcting the compilation errors

      Which error?

      Qt has to stay free or it will die.

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        rowHeight is a const method and more important it's not virtual.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          Qt Enthusiast
          wrote on last edited by
          #4

          how to get rowHeigt of first row in QtreeWidget

          JonBJ 1 Reply Last reply
          0
          • Q Qt Enthusiast

            how to get rowHeigt of first row in QtreeWidget

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @Qt-Enthusiast
            https://doc.qt.io/qt-5/qtreeview.html#rowHeight

            int 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 from QTableWidget, 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.

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved