I tried mixing the "spin box" and the "star" delegate examples like this:
#include <QApplication>
#include <QHeaderView>
#include <QItemSelectionModel>
#include <QStandardItemModel>
#include <QTableView>
#include "delegate.h"
#include "stardelegate.h"
int main(int argc, char *argv[])
{
tableView.setModel(&model);
SpinBoxDelegate delegateForColumn0;
StarDelegate delegateForColumn1;
tableView.setItemDelegateForColumn(0, &delegateForColumn0);
tableView.setItemDelegateForColumn(1, &delegateForColumn1);
tableView.horizontalHeader()->setStretchLastSection(true);
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 2; ++column) {
}
}
tableView.
setWindowTitle(QObject::tr("Spin Box/Star Delegates"));
tableView.show();
return app.exec();
}
#include <QApplication>
#include <QHeaderView>
#include <QItemSelectionModel>
#include <QStandardItemModel>
#include <QTableView>
#include "delegate.h"
#include "stardelegate.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QStandardItemModel model(4, 2);
QTableView tableView;
tableView.setModel(&model);
SpinBoxDelegate delegateForColumn0;
StarDelegate delegateForColumn1;
tableView.setItemDelegateForColumn(0, &delegateForColumn0);
tableView.setItemDelegateForColumn(1, &delegateForColumn1);
tableView.horizontalHeader()->setStretchLastSection(true);
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 2; ++column) {
QModelIndex index = model.index(row, column, QModelIndex());
model.setData(index, QVariant(row+1));
}
}
tableView.setWindowTitle(QObject::tr("Spin Box/Star Delegates"));
tableView.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
No stars yet?!
Bookmarks