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

QHeaderView setSectionResizeMode "segmentation fault"



  • Hi. I need ResizeToContents for VerticalHeader. My attempt:

    QHeaderView *vHeader = new QHeaderView(Qt::Orientation::Vertical, this);
    vHeader->setSectionResizeMode(Entity::SomeColumn, QHeaderView::ResizeToContents);
    ui->_tv->setVerticalHeader(vHeader);
    

    And I get segmentation fault in this line: setSectionResizeMode.
    How I can set heigh for my rows by context?


  • Lifetime Qt Champion

    I'm pretty sure it does not crash there but one line below. Please provide a minimal, compilable example to reproduce your problem.



  • The crash is probably caused by the fact that the view sections are not initialized until after you set the view's model. You must ensure that use of the two-parameter version of setSectionResizeMode happens after setModel. Take it out of the view constructor and put it somewhere else.


Log in to reply