This works for me:
#include <QApplication>
#include <QTableView>
#include <QStandardItemModel>
#include <QScrollBar>
{
public:
{
setStyleSheet( "QScrollBar:vertical { width: 25px; } ");
}
};
int main(int argc, char *argv[])
{
for (int i = 0; i < model.rowCount(); ++i) {
for (int j = 0; j < model.columnCount(); ++j) {
model.setItem(i, j, item);
}
}
view.setModel(&model);
view.setVerticalScrollBar(new WideScrollBar(&view));
view.show();
return app.exec();
}
#include <QApplication>
#include <QTableView>
#include <QStandardItemModel>
#include <QScrollBar>
class WideScrollBar: public QScrollBar
{
public:
WideScrollBar(QWidget *p = 0): QScrollBar(p)
{
setStyleSheet( "QScrollBar:vertical { width: 25px; } ");
}
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QStandardItemModel model(50, 3);
for (int i = 0; i < model.rowCount(); ++i) {
for (int j = 0; j < model.columnCount(); ++j) {
QStandardItem *item = new QStandardItem(QString("%1, %2").arg(i).arg(j));
model.setItem(i, j, item);
}
}
QTableView view;
view.setModel(&model);
view.setVerticalScrollBar(new WideScrollBar(&view));
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
and produces a customised scroll bar that works as expected. If the table had only one row I would not expect to see a vertical scroll bar at all.
Bookmarks