本文整理汇总了C++中QTableView::setWindowTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableView::setWindowTitle方法的具体用法?C++ QTableView::setWindowTitle怎么用?C++ QTableView::setWindowTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableView
的用法示例。
在下文中一共展示了QTableView::setWindowTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
TableModel *model = new TableModel(4, 2, &app);
//! [0]
QTableView *firstTableView = new QTableView;
QTableView *secondTableView = new QTableView;
//! [0]
//! [1]
firstTableView->setModel(model);
secondTableView->setModel(model);
//! [1]
firstTableView->horizontalHeader()->setModel(model);
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(QString("(%1, %2)").arg(row).arg(column)));
}
}
//! [2]
secondTableView->setSelectionModel(firstTableView->selectionModel());
//! [2]
firstTableView->setWindowTitle("First table view");
secondTableView->setWindowTitle("Second table view");
firstTableView->show();
secondTableView->show();
return app.exec();
}
示例2: main
//! [0]
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QStandardItemModel model(4, 2);
QTableView tableView;
tableView.setModel(&model);
SpinBoxDelegate delegate;
tableView.setItemDelegate(&delegate);
//! [0]
tableView.horizontalHeader()->setStretchLastSection(true);
//! [1]
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) * (column+1)));
}
//! [1] //! [2]
}
//! [2]
//! [3]
tableView.setWindowTitle(QObject::tr("Spin Box Delegate"));
tableView.show();
return app.exec();
}
示例3:
QTableView *createView(QSqlTableModel *model, const QString &title = "")
{
QTableView *view = new QTableView;
view->setModel(model);
view->setWindowTitle(title);
return view;
}
示例4: QSqlRelationalDelegate
QTableView *createView(const QString &title, QSqlTableModel *model)
{
QTableView *view = new QTableView;
view->setModel(model);
view->setItemDelegate(new QSqlRelationalDelegate(view));
view->setWindowTitle(title);
return view;
}
示例5: createView
void createView(const QString &title, QSqlQueryModel *model)
{
static int offset = 0;
QTableView *view = new QTableView;
view->setModel(model);
view->setWindowTitle(title);
view->move(100 + offset, 100 + offset);
offset += 20;
view->show();
}
示例6: defined
QTableView *createView(QSqlTableModel *model, const QString &title = "")
{
QTableView *view = new QTableView;
view->setModel(model);
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
Q_UNUSED(title)
#else
view->setWindowTitle(title);
#endif
return view;
}
示例7: createView
QTableView* createView(QSqlQueryModel *model, const QString &title = "")
{
QTableView *view = new QTableView;
view->setModel(model);
static int offset = 0;
view->setWindowTitle(title);
view->move(100 + offset, 100 + offset);
offset += 20;
view->show();
return view;
}
示例8: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
WeaponModel model;
QTableView view;
view.setModel(&model);
view.setWindowTitle(QObject::tr("自定义模型"));
view.resize(640,480);
view.show();
return app.exec();
}
示例9: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//MainWindow w;
//w.show();
ModelEx modelEx;
QTableView view;
view.setModel(&modelEx);
view.setWindowTitle(QObject::tr("modelEx"));
view.resize(400, 400);
view.show();
return a.exec();
}
示例10: createView
QTableView* createView(QSqlQueryModel *model, const QString &title = "")
{
QTableView *view = new QTableView;
view->setModel(model);
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
Q_UNUSED(title);
view->resizeColumnsToContents();
#else
static int offset = 0;
view->setWindowTitle(title);
view->move(100 + offset, 100 + offset);
offset += 20;
view->show();
#endif
return view;
}
示例11: createView
void createView(const QString &title, QSqlQueryModel *model)
{
static int offset = 0;
QTableView *view = new QTableView;
view->setModel(model);
view->setWindowTitle(title);
view->move(100 + offset, 100 + offset);
offset += 20;
view->show();
std::cout << "createView\n";
for (int i = 0; i < model->rowCount(); ++i) {
int id = model->record(i).value("id").toInt();
QString name = model->record(i).value("name").toString();
std::cout << name.toStdString() << "\n";
}
std::cout.flush();
}
示例12: main
int main( int argc, char** argv ) {
QApplication app( argc, argv );
CityEngine *engine = new CityEngine(QCoreApplication::instance());
CityTableModel *model = new CityTableModel(QCoreApplication::instance());
model->setInput(engine);
QListView* list = new QListView;
list->setModel( model );
list->setWindowTitle( "QListView" );
list->show();
QTreeView* tree = new QTreeView;
tree->setModel( model );
tree->setWindowTitle( "QTreeView" );
tree->show();
QTableView* table = new QTableView;
table->setModel( model );
table->setWindowTitle( "QTableView" );
table->show();
return app.exec();
}
示例13: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//! [0]
TableModel *model = new TableModel(8, 4, &app);
QTableView *table = new QTableView(0);
table->setModel(model);
QItemSelectionModel *selectionModel = table->selectionModel();
//! [0] //! [1]
QModelIndex topLeft;
QModelIndex bottomRight;
topLeft = model->index(0, 0, QModelIndex());
bottomRight = model->index(5, 2, QModelIndex());
//! [1]
//! [2]
QItemSelection selection(topLeft, bottomRight);
selectionModel->select(selection, QItemSelectionModel::Select);
//! [2]
//! [3]
QItemSelection toggleSelection;
topLeft = model->index(2, 1, QModelIndex());
bottomRight = model->index(7, 3, QModelIndex());
toggleSelection.select(topLeft, bottomRight);
selectionModel->select(toggleSelection, QItemSelectionModel::Toggle);
//! [3]
//! [4]
QItemSelection columnSelection;
topLeft = model->index(0, 1, QModelIndex());
bottomRight = model->index(0, 2, QModelIndex());
columnSelection.select(topLeft, bottomRight);
selectionModel->select(columnSelection,
QItemSelectionModel::Select | QItemSelectionModel::Columns);
QItemSelection rowSelection;
topLeft = model->index(0, 0, QModelIndex());
bottomRight = model->index(1, 0, QModelIndex());
rowSelection.select(topLeft, bottomRight);
selectionModel->select(rowSelection,
QItemSelectionModel::Select | QItemSelectionModel::Rows);
//! [4]
table->setWindowTitle("Selected items in a table model");
table->show();
table->resize(460, 280);
return app.exec();
}
示例14: showViewContextMenu
void ModelTestWidget::showViewContextMenu(const QPoint &pos)
{
const QModelIndex idx = m_handler->flatView()->indexAt(pos);
if (!idx.isValid())
return;
QMenu menu;
QAction *showCostItems = menu.addAction("show cost items");
const ParseData* data = m_handler->dataModel()->parseData();
QAction *ret = menu.exec(m_handler->flatView()->mapToGlobal(pos));
if (ret == showCostItems) {
///TODO: put this into a reusable class?
const Function *func = idx.data(DataModel::FunctionRole).value<const Function *>();
Q_ASSERT(func);
QTableView *view = new QTableView();
view->setAttribute(Qt::WA_DeleteOnClose, true);
const int rows = func->costItems().size();
const int columns = data->events().size() + data->positions().size() + 2;
QStandardItemModel *model = new QStandardItemModel(rows, columns, view);
int headerColumn = 0;
foreach (const QString &event, data->events()) {
model->setHeaderData(headerColumn++, Qt::Horizontal, event);
}
const int lastEventColumn = headerColumn;
foreach (const QString &pos, data->positions()) {
model->setHeaderData(headerColumn++, Qt::Horizontal, pos);
}
const int lastPosColumn = headerColumn;
model->setHeaderData(headerColumn++, Qt::Horizontal, "Call");
model->setHeaderData(headerColumn++, Qt::Horizontal, "Differring File");
Q_ASSERT(headerColumn == columns);
QVector<quint64> totalCosts;
totalCosts.fill(0, data->events().size());
for (int row = 0; row < rows; ++row) {
const CostItem *item = func->costItems().at(row);
for (int column = 0; column < columns; ++column) {
QVariant value;
if (column < lastEventColumn) {
value = item->cost(column);
totalCosts[column] += item->cost(column);
} else if (column < lastPosColumn) {
value = item->position(column - lastEventColumn);
} else if (column == lastPosColumn) {
if (item->call())
value = item->call()->callee()->name();
} else {
value = item->differingFile();
}
model->setData(model->index(row, column), value);
}
}
QStringList totalCostsStrings;
for (int i = 0; i < totalCosts.size(); ++i) {
totalCostsStrings << QString("%1: %2").arg(totalCosts.at(i)).arg(data->events().at(i));
}
view->setWindowTitle(totalCostsStrings.join(QLatin1String(", ")));
view->setModel(model);
view->show();
}
}
示例15: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QStandardItemModel model(4,4);
QTableView tableView;
tableView.setModel(&model);
DateDelegate dateDelegate;
tableView.setItemDelegateForColumn(1,&dateDelegate);
ComboDelegate comboDelegate;
tableView.setItemDelegateForColumn(2,&comboDelegate);
SpinDelegate spinDelegate;
tableView.setItemDelegateForColumn(3,&spinDelegate);
model.setHeaderData(0,Qt::Horizontal,QObject::tr("姓名"));
model.setHeaderData(1,Qt::Horizontal,QObject::tr("生日"));
model.setHeaderData(2,Qt::Horizontal,QObject::tr("职业"));
model.setHeaderData(3,Qt::Horizontal,QObject::tr("收入"));
QFile file("test.txt");
if(file.open(QFile::ReadOnly|QFile::Text))
{
QTextStream stream(&file);
QString line;
model.removeRows(0,model.rowCount(QModelIndex()),QModelIndex());
int row =0;
do{
line = stream.readLine();
if(!line.isEmpty())
{
model.insertRows(row,1,QModelIndex());
QStringList pieces = line.split(",",QString::SkipEmptyParts);
model.setData(model.index(row,0,QModelIndex()),pieces.value(0));
model.setData(model.index(row,1,QModelIndex()),pieces.value(1));
model.setData(model.index(row,2,QModelIndex()),pieces.value(2));
model.setData(model.index(row,3,QModelIndex()),pieces.value(3));
row++;
}
}while(!line.isEmpty());
file.close();
}
tableView.setWindowTitle(QObject::tr("Delegate"));
tableView.show();
return a.exec();
}