Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Calculating QTreeView height #28

Open
buelowp opened this issue Dec 21, 2023 · 0 comments
Open

Question: Calculating QTreeView height #28

buelowp opened this issue Dec 21, 2023 · 0 comments

Comments

@buelowp
Copy link

buelowp commented Dec 21, 2023

I've tried this a few ways, but haven't sorted it yet. Do you know an easy way to calculate the entire height for the container widget that is the QTreeView? I've tried to use QFontMetrics and the number of rows, but it's incomplete. Just getting a size on the view returns 480 no matter what.

This example is what I current do to set the view. It's my current height calculation, though it ignores a lot of details. I'm just hoping you may know a better way than to calculate all the internals.

    m_layout = new QVBoxLayout();
    m_data = new QJsonModel();
    m_view = new QTreeView();

    m_data->load(obj);
    m_view->setModel(m_data);
    m_layout->addWidget(m_view);
    QFontMetrics fm = m_view->fontMetrics();
    int r = m_data->rowCount();
    int h = fm.height() * r;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant