Hello,
I have QWidget with a QTableWidget and 2 QScrollBars, one horizontal and one vertical.
I cannot use the scrollbars of the QTableWidget because the scrollbars reach up to the table headers, which I don't want.
When this widget is visible (see code below) I cannot see the scrollbars, they never appear. Do you know why?
Thank you.
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
DynamicTable::DynamicTable(int rows, int columns, QWidget * parent)
: QWidget(parent)
{
QScrollBar vScrollBar(Qt::Vertical);
QScrollBar hScrollBar(Qt::Horizontal);
vScrollBar.setMinimum(0);
vScrollBar.setSingleStep(1);
vScrollBar.setMaximum(50);
vScrollBar.setValue(10);
vScrollBar.setPageStep(10);
hScrollBar.setMinimum(0);
hScrollBar.setSingleStep(1);
hScrollBar.setMaximum(50);
hScrollBar.setValue(10);
hScrollBar.setPageStep(10);
hScrollBar.setMinimumSize(QSize(50,50));
QSizePolicy sp(QSizePolicy::Minimum,QSizePolicy::Minimum);
hScrollBar.setSizePolicy(sp);
QHBoxLayout * horizontalLayout = new QHBoxLayout();
QVBoxLayout * verticalLayout = new QVBoxLayout();
QTableWidget table;
table.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
table.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
table.setRowCount(rows);
table.setColumnCount(columns);
horizontalLayout->addWidget(&vScrollBar);
horizontalLayout->addWidget(&table);
vScrollBar.setVisible(true);
verticalLayout->addLayout(horizontalLayout);
verticalLayout->addWidget(&hScrollBar);
hScrollBar.setVisible(true);
setLayout(verticalLayout); fillTable(); // some function which adds stuff in the QTableWidget
}
|