29 #include <QtWidgets/QtWidgets>
39 { QT_TR_NOOP(
"0. Default"),
40 "Please provide instructions",
43 { QT_TR_NOOP(
"1. Autoscroll"),
45 "<li>Press and hold on section 9 of vertical header.<br/>"
46 "<em>(all cells in the row will be selected)</em>"
48 "<li>Extend the selection by moving the mouse down.<br/>"
49 "<em>(selection will extend to the next rows)</em>"
51 "<li>Continue to move the mouse down and outside the window geometry.<br/>"
52 "<em>(The view should scroll automatically and the selection should still extend)</em>"
54 "<li>While still holding the button, do the same in the opposite direction, i.e. move mouse up and outside the window geometry.<br/>"
55 "<em>(Verify that the view scrolls automatically and the selection changes)</em>"
57 "<li>Verify that it works in the other dimension, i.e Press and hold section 9 of the horizontal header.<br/>"
58 "<em>All cells in the column will be selected</em>"
60 "<li>Extend the selection by moving the mouse to the far right and outside the window geometry.<br/>"
61 "<em>(selection will extend to the next columns)</em>"
63 "<li>Verify that it works in the opposite direction (i.e. move mouse to the left of the window geometry).<br/>"
64 "<em>(Verify that the view scrolls automatically and the selection changes)</em>"
80 if (
sizeof(
tasks) > 0)
101 for (
size_t i = 0;
i <
sizeof(
tasks) /
sizeof(
tasks[0]); ++
i) {
105 connect(combo,
SIGNAL(currentIndexChanged(
int)),
this,
SLOT(on_taskCombo_currentIndexChanged(
int)));
107 form->addRow(
tr(
"Choose task:"), combo);
140 m.setColumnCount(250);
148 void on_ckMovable_toggled(
bool arg)
154 void on_cbSelectionMode_currentIndexChanged(
int idx)
159 void on_taskCombo_currentIndexChanged(
int idx)
196 m_tv->setUpdatesEnabled(
false);
198 m_hv->blockSignals(
true);
200 m_hv->blockSignals(
false);
205 #define DO_CORRECT_OFFSET_AND_SB
206 #ifdef DO_CORRECT_OFFSET_AND_SB
208 int newoffset =
offset - leftRemoved;
212 if (newoffset > 0 && newoffset >= m_hv->
count() * newsize - m_tv->viewport()->width())
217 m_tv->horizontalScrollBar()->blockSignals(
true);
218 m_tv->horizontalScrollBar()->setRange(0, m_hv->
count() * newsize - m_tv->viewport()->width() );
219 m_tv->horizontalScrollBar()->setValue(newoffset);
220 m_tv->horizontalScrollBar()->blockSignals(
false);
222 m_tv->setUpdatesEnabled(
true);
225 int main(
int argc,
char *argv[])
242 #include "qheaderviewtest1.moc"
small capitals from c petite p scientific i
[1]
void setHorizontalScrollMode(ScrollMode mode)
SelectionMode selectionMode
which selection mode the view operates in
void setSelectionMode(QAbstractItemView::SelectionMode mode)
The QApplication class manages the GUI application's control flow and main settings.
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
void addLayout(QLayout *layout, int stretch=0)
The QCheckBox widget provides a checkbox with a text label.
The QComboBox widget is a combined button and popup list.
void addItem(const QString &text, const QVariant &userData=QVariant())
void addItems(const QStringList &texts)
void setCurrentIndex(int index)
QGraphicsObject * parent
the parent of the item
The QGroupBox widget provides a group box frame with a title.
The QLabel widget provides a text or image display.
void setText(const QString &)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QObject class is the base class of all Qt objects.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
void setObjectName(const QString &name)
The QStandardItemModel class provides a generic model for storing custom data.\inmodule QtGui.
The QTableView class provides a default model/view implementation of a table view.
void setModel(QAbstractItemModel *model) override
QHeaderView * horizontalHeader() const
QHeaderView * verticalHeader() const
The QVBoxLayout class lines up widgets vertically.
QString title
the window's title in the windowing system
SomeHandler(QHeaderView *hv, QTableView *tv)
void slotSectionResized(int, int, int)
[Window class definition]
QLabel * m_taskInstructions
Window(QWidget *parent=nullptr)
QComboBox * cbSelectionMode
QList< QString > QStringList
GLenum GLuint GLintptr offset
QApplication app(argc, argv)
[0]
const char * instructions