c++qtqt5qwidgetqheaderview

What's the difference between two QHeaderView signals?


On Qt doc website in QHeaderView class i found two signals with similar descriptions:

void QHeaderView::sectionDoubleClicked(int logicalIndex)

and

void QHeaderView::sectionHandleDoubleClicked(int logicalIndex)

what's the difference between the two of these? When should I use the first, and when the other?


Solution

  • Although the documentation strings are exactly the same,

    void QHeaderView::sectionDoubleClicked(int logicalIndex) This signal is emitted when a section is double-clicked. The section's logical index is specified by logicalIndex.

    [signal]void QHeaderView::sectionHandleDoubleClicked(int logicalIndex) This signal is emitted when a section is double-clicked. The section's logical index is specified by logicalIndex.

    The signals are emitted in different cases. From KDE's copy of Qt5,

    void QHeaderView::mouseDoubleClickEvent(QMouseEvent *e)
    {
    ...
        int handle = d->sectionHandleAt(pos);
        if (handle > -1 && sectionResizeMode(handle) == Interactive) {
            emit sectionHandleDoubleClicked(handle);
    ...
        } else {
            emit sectionDoubleClicked(logicalIndexAt(e->position().toPoint()));
        }
    }
    

    The documentation doesn't make it particularly clear, though, when "handles" might be present and when they aren't. At a guess, if your sections are resizable you may get a handle -- for resizing -- and then you can (double) click on either the handle or the section-body.