本文整理汇总了C++中QTableView::setAlternatingRowColors方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableView::setAlternatingRowColors方法的具体用法?C++ QTableView::setAlternatingRowColors怎么用?C++ QTableView::setAlternatingRowColors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableView
的用法示例。
在下文中一共展示了QTableView::setAlternatingRowColors方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setModel
void ReceiveCoinsDialog::setModel(WalletModel *_model)
{
this->model = _model;
if(_model && _model->getOptionsModel())
{
_model->getRecentRequestsTableModel()->sort(RecentRequestsTableModel::Date, Qt::DescendingOrder);
connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
updateDisplayUnit();
QTableView* tableView = ui->recentRequestsView;
tableView->verticalHeader()->hide();
tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
tableView->setModel(_model->getRecentRequestsTableModel());
tableView->setAlternatingRowColors(true);
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
tableView->setSelectionMode(QAbstractItemView::ContiguousSelection);
tableView->setColumnWidth(RecentRequestsTableModel::Date, DATE_COLUMN_WIDTH);
tableView->setColumnWidth(RecentRequestsTableModel::Label, LABEL_COLUMN_WIDTH);
tableView->setColumnWidth(RecentRequestsTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
connect(tableView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this,
SLOT(recentRequestsView_selectionChanged(QItemSelection, QItemSelection)));
// Last 2 columns are set by the columnResizingFixer, when the table geometry is ready.
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH, this);
}
示例2: loadNetwork
void MainWindow::loadNetwork()
{
setWindowTitle("Qt-dtnet - " + ws.networkFilename);
delete networkToolBox;
networkToolBox = new QToolBox();
ui->dockProperties->setWidget(networkToolBox);
QTableView *propertiesTree;
std::map<std::string,Population>::iterator i;
for (i = ws.net->populations.begin(); i != ws.net->populations.end(); ++i)
{
propertiesTree = new QTableView();
propertiesTree->setAlternatingRowColors(false);
propertiesTree->setSelectionBehavior( QAbstractItemView::SelectRows );
propertiesTree->setWordWrap( false );
// propertiesTree->setAnimated( false );
networkToolBox->addItem(propertiesTree, QString::fromStdString(i->first));
propertiesModel = new PropModel( &(i->second) );
propertiesTree->setModel(propertiesModel);
}
networkView->replaceNetwork( ws.net );
networkView->show();
if ( ws.trial->isReady() && ws.net->isReady() ) ui->actionRun_Simulation->setEnabled( true );
}
示例3: initializeTable
void availableRoomsWindow::initializeTable()
{
qDebug() << Q_FUNC_INFO;
QTableView* tableView = ui->tableView;
tableView->setModel(parameters->availableRoomsMdl);
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
tableView->setAlternatingRowColors(true);
tableView->setSelectionMode(QAbstractItemView::SingleSelection);
tableView->horizontalHeader()->setHighlightSections(false);
tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
tableView->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
tableView->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
tableView->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
tableView->horizontalHeader()->setSectionResizeMode(5, QHeaderView::ResizeToContents);
tableView->hideColumn(1);
tableView->hideColumn(6);
tableView->hideColumn(7);
tableView->hideColumn(8);
tableView->hideColumn(9);
tableView->hideColumn(10);
tableView->hideColumn(11);
tableView->hideColumn(12);
tableView->hideColumn(13);
tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
ui->tableView->verticalHeader()->setDefaultSectionSize(23);
}
示例4: QWidget
ErrorListView::ErrorListView(QWidget* parent)
: QWidget(parent),
m_model(0)
{
m_model = new ErrorListModel(this);
QTableView* tableView = new QTableView;
tableView->setItemDelegate(new ItemDelegate);
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
tableView->setAlternatingRowColors(true);
tableView->setShowGrid(false);
tableView->verticalHeader()->hide();
tableView->setModel(m_model);
#ifdef STROMX_STUDIO_QT4
tableView->horizontalHeader()->setResizeMode(ErrorListModel::TIME, QHeaderView::Interactive);
tableView->horizontalHeader()->setResizeMode(ErrorListModel::DESCRIPTION, QHeaderView::Stretch);
#else
tableView->horizontalHeader()->setSectionResizeMode(ErrorListModel::TIME, QHeaderView::Interactive);
tableView->horizontalHeader()->setSectionResizeMode(ErrorListModel::DESCRIPTION, QHeaderView::Stretch);
#endif // STROMX_STUDIO_QT4
QPushButton* clearButton = new QPushButton(tr("Clear error log"));
connect(clearButton, SIGNAL(clicked()), m_model, SLOT(clear()));
QHBoxLayout* buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(clearButton);
buttonLayout->addStretch();
QVBoxLayout* mainLayout = new QVBoxLayout;
mainLayout->addWidget(tableView);
mainLayout->addLayout(buttonLayout);
setLayout(mainLayout);
}
示例5: MakeTableView
// Table factory
QTableView* MakeTableView(QAbstractItemModel* model, bool sortingEnabled = true, uint32_t modelSortColumn = 0)
{
class MyTable : public QTableView
{
public:
QStyleOptionViewItem viewOptions() const override
{
QStyleOptionViewItem option = QTableView::viewOptions();
option.decorationAlignment = Qt::AlignHCenter | Qt::AlignCenter;
option.decorationPosition = QStyleOptionViewItem::Top;
return option;
}
void mouseMoveEvent(QMouseEvent* event) override
{
QModelIndex index = indexAt(event->pos());
if (index.isValid()) {
QVariant data = model()->data(index, PlayerTableModel::CursorRole);
Qt::CursorShape shape = Qt::ArrowCursor;
if (!data.isNull()) {
shape = Qt::CursorShape(data.toInt());
}
setCursor(shape);
}
QTableView::mouseMoveEvent(event);
}
};
QTableView* tableView = new MyTable();
tableView->setModel(model);
tableView->setSortingEnabled(sortingEnabled);
if (sortingEnabled) {
tableView->sortByColumn(FindColumn(model, modelSortColumn));
}
tableView->verticalHeader()->hide();
tableView->setAlternatingRowColors(true);
tableView->verticalHeader()->setDefaultSectionSize(15);
tableView->resizeColumnsToContents();
tableView->horizontalHeader()->setStretchLastSection(true);
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
tableView->setSelectionMode(QAbstractItemView::SingleSelection);
tableView->setFocusPolicy(Qt::StrongFocus);
// enable mouse tracking
tableView->setMouseTracking(true);
tableView->viewport()->setMouseTracking(true);
tableView->installEventFilter(this);
tableView->viewport()->installEventFilter(this);
return tableView;
}
示例6: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMap<QString, double> currencyMap;
currencyMap.insert("AUD", 1.3257);
currencyMap.insert("CHF", 1.2980);
currencyMap.insert("SGD", 1.6911);
currencyMap.insert("USD", 1.0000);
CurrencyModel currencyModel(currencyMap);
QTableView tableView;
tableView.setModel(¤cyModel);
tableView.setAlternatingRowColors(true);
tableView.show();
return a.exec();
}
示例7: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//QListView view;
QTableView view;
view.setSortingEnabled(false);
view.horizontalHeader()->setStretchLastSection(true);
view.horizontalHeader()->setVisible(false);
view.verticalHeader()->setVisible(false);
MillionRows model(Q_NULLPTR);
view.setModel(&model);
view.setAlternatingRowColors(true);
view.setStyleSheet("alternate-background-color: green;background-color: white;");
view.setItemDelegateForColumn(0, new TableStyleDelegate());
view.resizeRowsToContents(); // impact performance - force call sizeHint
view.show();
return a.exec();
}
示例8: setModel
void ReceiveCoinsDialog::setModel(WalletModel *_model)
{
this->model = _model;
if(_model && _model->getOptionsModel())
{
_model->getRecentRequestsTableModel()->sort(RecentRequestsTableModel::Date, Qt::DescendingOrder);
connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
updateDisplayUnit();
QTableView* tableView = ui->recentRequestsView;
tableView->verticalHeader()->hide();
tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
tableView->setModel(_model->getRecentRequestsTableModel());
tableView->setAlternatingRowColors(true);
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
tableView->setSelectionMode(QAbstractItemView::ContiguousSelection);
tableView->setColumnWidth(RecentRequestsTableModel::Date, DATE_COLUMN_WIDTH);
tableView->setColumnWidth(RecentRequestsTableModel::Label, LABEL_COLUMN_WIDTH);
tableView->setColumnWidth(RecentRequestsTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
connect(tableView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this,
SLOT(recentRequestsView_selectionChanged(QItemSelection, QItemSelection)));
// Last 2 columns are set by the columnResizingFixer, when the table geometry is ready.
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH, this);
if (model->wallet().getDefaultAddressType() == OutputType::BECH32) {
ui->useBech32->setCheckState(Qt::Checked);
} else {
ui->useBech32->setCheckState(Qt::Unchecked);
}
// eventually disable the main receive button if private key operations are disabled
ui->receiveButton->setEnabled(!model->privateKeysDisabled());
}
示例9: QComboBox
MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags f) :
QMainWindow(parent, f),
configurationModels(),
geometryModels(),
ikAlgorithmComboBox(new QComboBox(this)),
ikDurationSpinBox(new QSpinBox(this)),
ikIterationsSpinBox(new QSpinBox(this)),
ikJacobianComboBox(new QComboBox(this)),
kinematicModels(),
operationalModels(),
scene(),
configurationDelegates(),
configurationDockWidget(new QDockWidget(this)),
configurationTabWidget(new QTabWidget(this)),
configurationViews(),
gradientBackground(),
operationalDelegates(),
operationalDockWidget(new QDockWidget(this)),
operationalTabWidget(new QTabWidget(this)),
operationalViews(),
saveImageWithAlphaAction(new QAction(this)),
saveImageWithoutAlphaAction(new QAction(this)),
saveSceneAction(new QAction(this)),
server(new Server(this)),
viewer(nullptr)
{
MainWindow::singleton = this;
SoQt::init(this);
SoDB::init();
SoGradientBackground::initClass();
std::shared_ptr<rl::sg::Factory> geometryFactory;
std::string geometryFilename = QApplication::arguments()[1].toStdString();
if ("urdf" == geometryFilename.substr(geometryFilename.length() - 4, 4))
{
geometryFactory = std::make_shared<rl::sg::UrdfFactory>();
}
else
{
geometryFactory = std::make_shared<rl::sg::XmlFactory>();
}
this->scene = std::make_shared<rl::sg::so::Scene>();
geometryFactory->load(geometryFilename, this->scene.get());
for (int i = 2; i < QApplication::arguments().size(); ++i)
{
std::shared_ptr<rl::mdl::Factory> kinematicFactory;
std::string kinematicFilename = QApplication::arguments()[i].toStdString();
if ("urdf" == kinematicFilename.substr(kinematicFilename.length() - 4, 4))
{
kinematicFactory = std::make_shared<rl::mdl::UrdfFactory>();
}
else
{
kinematicFactory = std::make_shared<rl::mdl::XmlFactory>();
}
this->geometryModels.push_back(this->scene->getModel(i - 2));
this->kinematicModels.push_back(std::dynamic_pointer_cast<rl::mdl::Kinematic>(kinematicFactory->create(kinematicFilename)));
}
for (std::size_t i = 0; i < this->kinematicModels.size(); ++i)
{
ConfigurationDelegate* configurationDelegate = new ConfigurationDelegate(this);
configurationDelegate->id = i;
this->configurationDelegates.push_back(configurationDelegate);
ConfigurationModel* configurationModel = new ConfigurationModel(this);
configurationModel->id = i;
this->configurationModels.push_back(configurationModel);
QTableView* configurationView = new QTableView(this);
#if QT_VERSION >= 0x050000
configurationView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
#else // QT_VERSION
configurationView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
#endif // QT_VERSION
configurationView->horizontalHeader()->hide();
configurationView->setAlternatingRowColors(true);
configurationView->setItemDelegate(configurationDelegate);
configurationView->setModel(configurationModel);
this->configurationViews.push_back(configurationView);
this->configurationTabWidget->addTab(configurationView, QString::number(i));
OperationalDelegate* operationalDelegate = new OperationalDelegate(this);
this->operationalDelegates.push_back(operationalDelegate);
OperationalModel* operationalModel = new OperationalModel(this);
operationalModel->id = i;
this->operationalModels.push_back(operationalModel);
QTableView* operationalView = new QTableView(this);
#if QT_VERSION >= 0x050000
operationalView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
#else // QT_VERSION
//.........这里部分代码省略.........
示例10: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget * main_wg = new QWidget;
// cria um objeto "splitter" para compartilhar widgets:
QSplitter *splitter = new QSplitter(main_wg);
// cria um "model" usando o "StandardModel"
QStandardItemModel *model = new QStandardItemModel;
const int totCols = 3;
int col;
// define os títulos das colunas:
for (col = 0; col < totCols; ++col)
{
model->setHorizontalHeaderItem(col,
new QStandardItem( QString("COL-%1").arg(col+1) ) );
}
// alimenta linhas, colunas e sub-níveis:
QStandardItem *parentItem = model->invisibleRootItem();
const int iniLevel = 0;
const int totLevels= 3;
QString prevRows("");
QVector<QSize> vec_ColsRows; // colunas, linhas de cada nível
vec_ColsRows.reserve( totLevels );
// quantidade-colunas, quantidade-linhas
vec_ColsRows << QSize(3,10) << QSize(3,3) << QSize(3,2) ;
populate_model ( parentItem, vec_ColsRows,
iniLevel, prevRows);
// Neste exemplo,
// O "model" foi alimentado com linhas, colunas e sub-níveis:
// E serão criadas 4 "views" (uma "tree", uma "table", uma "list" e uma "comboBox")
// relacionadas ao mesmo "model";
// Cada "view" exibe os dados de uma determinada maneira;
// 1- ==== a primeira "view" é uma "tree":
QTreeView *tree = new QTreeView(splitter);
tree->setModel(model);
// habilita classificação na tree:
tree->setSortingEnabled(true);
// classifica
tree->sortByColumn(0);
// expande toda a árvore:
tree->expandAll();
// força largura de todas as colunas
// para exibição completa do texto dos seus itens
for (col = 0; col < totCols; ++col)
tree->resizeColumnToContents(col);
// configura o header para permitir mudança na ordem de classificacão:
QHeaderView * hdrTree = tree->header();
hdrTree->setClickable (true);
hdrTree->setSortIndicator(0,Qt::AscendingOrder);
hdrTree->setSortIndicatorShown(true);
hdrTree->setMovable(true); // permite mover colunas do header
// 2- ==== a segunda "view" é uma "table"
QTableView *table = new QTableView(splitter);
table->setModel(model);
table->setAlternatingRowColors(true);
// habilita classificação na table:
table->setSortingEnabled(true);
// classifica
table->sortByColumn(0);
// configura o header para permitir mudança na ordem de classificacão:
QHeaderView * hdrTable = table->horizontalHeader();
hdrTable->setClickable (true);
hdrTable->setSortIndicator(0,Qt::AscendingOrder);
hdrTable->setSortIndicatorShown(true);
hdrTable->setMovable(true); // permite mover colunas do header
// 3- ==== a terceira view é uma "list":
QListView *list = new QListView(splitter);
list->setModel(model);
// 4- ==== a quarta "view" é uma "comboBox"
QComboBox *combo = new QComboBox;
combo->setModel(model);
// configura a "splitter" definindo a largura de cada "view"
int width = 800;
QList< int > cols;
cols << int(width* 0.45) << int(width*0.45) << int(width*0.1);
splitter->setSizes(cols);
// layout para agrupar a "combo" e a "splitter":
QGridLayout * glayMain = new QGridLayout;
main_wg->setLayout( glayMain);
glayMain->addWidget( combo, 0, 1); // linha 0, coluna 0;
glayMain->setRowMinimumHeight(1, glayMain->verticalSpacing() * 4); // linha 1: linha de separação
glayMain->addWidget( splitter, 2, 0, 1, 3 ); // linha 2, coluna 0, rowSpan 1, colSpan 3
main_wg->setWindowTitle("06_standard - 4 'views' usando o mesmo 'model' (StandardModel) - recursivo");
main_wg->resize(800,500);
//.........这里部分代码省略.........
示例11: QWidget
TransactionView::TransactionView(QWidget *parent) :
QWidget(parent), model(0), transactionProxyModel(0),
transactionView(0)
{
// Build filter row
setContentsMargins(0,0,0,0);
QHBoxLayout *hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0,0,0,0);
#ifdef Q_OS_MAC
hlayout->setSpacing(5);
hlayout->addSpacing(0);
#else
hlayout->setSpacing(0);
hlayout->addSpacing(0);
#endif
dateWidget = new QComboBox(this);
dateWidget->setContentsMargins(1,1,1,1);
#ifdef Q_OS_MAC
dateWidget->setFixedWidth(121);
#else
dateWidget->setFixedWidth(120);
#endif
dateWidget->setContentsMargins(1,1,1,1);
dateWidget->addItem(tr("All"), All);
dateWidget->addItem(tr("Today"), Today);
dateWidget->addItem(tr("This week"), ThisWeek);
dateWidget->addItem(tr("This month"), ThisMonth);
dateWidget->addItem(tr("Last month"), LastMonth);
dateWidget->addItem(tr("This year"), ThisYear);
dateWidget->addItem(tr("Range..."), Range);
hlayout->addWidget(dateWidget);
typeWidget = new QComboBox(this);
#ifdef Q_OS_MAC
typeWidget->setFixedWidth(121);
#else
typeWidget->setFixedWidth(120);
#endif
typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES);
typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) |
TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther));
typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) |
TransactionFilterProxy::TYPE(TransactionRecord::SendToOther));
typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf));
typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated));
typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other));
typeWidget->setContentsMargins(1,1,1,1);
hlayout->addWidget(typeWidget);
addressWidget = new QLineEdit(this);
#if QT_VERSION >= 0x040700
/* Do not move this to the XML file, Qt before 4.7 will choke on it */
addressWidget->setPlaceholderText(tr("Enter address or label to search"));
addressWidget->setContentsMargins(1,1,1,1);
#endif
hlayout->addWidget(addressWidget);
amountWidget = new QLineEdit(this);
#if QT_VERSION >= 0x040700
/* Do not move this to the XML file, Qt before 4.7 will choke on it */
amountWidget->setPlaceholderText(tr("Min amount"));
amountWidget->setContentsMargins(1,1,1,1);
#endif
#ifdef Q_OS_MAC
amountWidget->setFixedWidth(97);
#else
amountWidget->setFixedWidth(100);
#endif
amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this));
hlayout->addWidget(amountWidget);
QVBoxLayout *vlayout = new QVBoxLayout(this);
vlayout->setContentsMargins(0,0,0,0);
vlayout->setSpacing(0);
QTableView *view = new QTableView(this);
vlayout->addLayout(hlayout);
vlayout->addWidget(createDateRangeWidget());
vlayout->addWidget(view);
vlayout->setSpacing(0);
view->setAlternatingRowColors(false);
int width = view->verticalScrollBar()->sizeHint().width();
// Cover scroll bar width with spacing
#ifdef Q_OS_MAC
hlayout->addSpacing(width+2);
#else
hlayout->addSpacing(width);
#endif
// Always show scroll bar
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
view->setTabKeyNavigation(false);
view->setContextMenuPolicy(Qt::CustomContextMenu);
//.........这里部分代码省略.........