[Qt-interest] How can I receive information about hiding columns (QHeaderView)

Paul Colby qt at colby.id.au
Fri Oct 30 20:55:26 CET 2009


Hi lurii,

I don't think there's any built-in signal to notify you when columns
are hidden / shown.  However, since columns aren't hidden / shown
automatically (as far as I know) but only in response to your code,
you can create your own sectionHidden and/or sectionShown signals, and
emit them yourself whenever you call QHeaderView::setSectionHidden.

Of course if QHeaderView::setSectionHidden is being called outside of
your own classes / code, then that might not be possible.

A good way might be to override the QHeaderView::setSectionHidden
function itself.

eg:

void MyHeaderView::setSectionHidden(int logicalIndex, bool hide)
{
    QHeaderView::setSectionHidden(logicalIndex,hide); // Do the actual
showing / hiding.
    emit hide ? sectionHidden(logicalIndex) : sectionShown(logicalIndex);
}

In this case, since QHeaderView::setSectionHidden is *not* virtual,
you'll need to cast to call your override.

eg: tableView->horizontalHeader()->setSectionHidden(...); // This will
*not* call your override.

but assuming that tableView uses your custom header, then do something
like this:

<MyHeaderView*>(tableView->horizontalHeader())->setSectionHidden(...);
// Will emit sectionHidden / sectionShown signals :)

... hope that helps you along ;)

paul.

2009/10/31 Iurii Gordiienko <hordi at ukr.net>:
> Hi
> How can I know about hiding (showing) columns after executing functions like
> showSection and hideSection of the QHeaderView?
> Also I need know when column was moved...
> Qt-4.5.3
>
> Thanks
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>



-- 
http://colby.id.au



More information about the Qt-interest-old mailing list