#include <qdatetime.h>
#include <qlineedit.h>
#include <qspinbox.h>
+#include <qtreeview.h>
+#include <qtableview.h>
+#include <qheaderview.h>
#include <qstyleditemdelegate.h>
#include <private/qabstractitemview_p.h>
#include <private/qabstractitemmodel_p.h>
QScrollBar *verticalScroll = verticalScrollBar();
QScrollBar *horizontalScroll = horizontalScrollBar();
+ // QHeaderView does not (normally) have scrollbars
+ // It needs to use its parents scroll instead
+ QHeaderView *hv = qobject_cast<QHeaderView*>(this);
+ if (hv) {
+ QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea*>(parentWidget());
+ if (parent) {
+ if (hv->orientation() == Qt::Horizontal) {
+ if (!hv->horizontalScrollBar() || !hv->horizontalScrollBar()->isVisible())
+ horizontalScroll = parent->horizontalScrollBar();
+ } else {
+ if (!hv->verticalScrollBar() || !hv->verticalScrollBar()->isVisible())
+ verticalScroll = parent->verticalScrollBar();
+ }
+ }
+ }
+
int verticalStep = verticalScroll->pageStep();
int horizontalStep = horizontalScroll->pageStep();
if (d->autoScrollCount < qMax(verticalStep, horizontalStep))
return;
}
case QHeaderViewPrivate::MoveSection: {
+ if (d->shouldAutoScroll(e->pos()))
+ d->startAutoScroll();
if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance()
|| !d->sectionIndicator->isHidden()) {
int visual = visualIndexAt(pos);
QApplication app(argc, argv);
QTableView tv;
QStandardItemModel m;
- m.setRowCount(10);
- m.setColumnCount(36);
+ m.setRowCount(500);
+ m.setColumnCount(250);
tv.setModel(&m);
SomeHandler handler(tv.horizontalHeader(), &tv);
- tv.horizontalHeader()->setDefaultSectionSize(50);
+ tv.horizontalHeader()->setDefaultSectionSize(30);
+ tv.show();
tv.horizontalHeader()->setSectionsMovable(true);
- tv.showMaximized();
+ tv.verticalHeader()->setSectionsMovable(true);
app.exec();
}
-
#include "qheaderviewtest1.moc"