本文整理汇总了C++中QStandardItemModel::insertColumns方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItemModel::insertColumns方法的具体用法?C++ QStandardItemModel::insertColumns怎么用?C++ QStandardItemModel::insertColumns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItemModel
的用法示例。
在下文中一共展示了QStandardItemModel::insertColumns方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
DlgFilletEdges::DlgFilletEdges(Part::FilletBase* fillet, QWidget* parent, Qt::WFlags fl)
: QWidget(parent, fl), ui(new Ui_DlgFilletEdges()), d(new DlgFilletEdgesP())
{
ui->setupUi(this);
d->object = 0;
d->selection = new EdgeSelection(d->object);
Gui::Selection().addSelectionGate(d->selection);
d->fillet = fillet;
d->connectApplicationDeletedObject = App::GetApplication().signalDeletedObject
.connect(boost::bind(&DlgFilletEdges::onDeleteObject, this, _1));
d->connectApplicationDeletedDocument = App::GetApplication().signalDeleteDocument
.connect(boost::bind(&DlgFilletEdges::onDeleteDocument, this, _1));
// set tree view with three columns
QStandardItemModel* model = new FilletRadiusModel(this);
connect(model, SIGNAL(toggleCheckState(const QModelIndex&)),
this, SLOT(toggleCheckState(const QModelIndex&)));
model->insertColumns(0,3);
model->setHeaderData(0, Qt::Horizontal, tr("Edges to fillet"), Qt::DisplayRole);
model->setHeaderData(1, Qt::Horizontal, tr("Start radius"), Qt::DisplayRole);
model->setHeaderData(2, Qt::Horizontal, tr("End radius"), Qt::DisplayRole);
ui->treeView->setRootIsDecorated(false);
ui->treeView->setItemDelegate(new FilletRadiusDelegate(this));
ui->treeView->setModel(model);
QHeaderView* header = ui->treeView->header();
header->setResizeMode(0, QHeaderView::Stretch);
header->setDefaultAlignment(Qt::AlignLeft);
header->setMovable(false);
on_filletType_activated(0);
findShapes();
}
示例2: QWidget
Widget::Widget(QWidget *parentWidget)
: QWidget(parentWidget)
{
QStandardItemModel *model = new QStandardItemModel();
QModelIndex parent;
for (int i = 0; i < 4; ++i) {
parent = model->index(0, 0, parent);
model->insertRows(0, 1, parent);
model->insertColumns(0, 1, parent);
QModelIndex index = model->index(0, 0, parent);
model->setData(index, i);
}
}
示例3: showEvents
/** time is used to select first event with this time */
void EventList::showEvents(TraceModelPtr& traceModel, const Time& time)
{
//? maybe better to clear model, not to delete it
delete model();
events.clear();
QStandardItemModel* modelPtr = new QStandardItemModel(this);
modelPtr->insertColumns(0, 2);
QTreeView::setModel(modelPtr);
connect(this->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),this,
SLOT(eventListRowChanged()));
int nearestEvent = -1;
Time minDistance;//? min time range not initialized
int row = 0;
for(auto eventPtr = traceModel->getNextEvent(); eventPtr ;eventPtr = traceModel->getNextEvent(), ++row)
{
model()->insertRow(row);
if (nearestEvent == -1 || distance(time, eventPtr->time) < minDistance)
{
nearestEvent = row;
minDistance = distance(time, eventPtr->time);
}
QModelIndex index = model()->index(row, 0, QModelIndex());
model()->setData(index, eventPtr->time.toString());
index = model()->index(row, 1, QModelIndex());
model()->setData(index, eventPtr->shortDescription());
model()->setData(index, eventPtr->shortDescription(), Qt::ToolTipRole);
events.push_back(eventPtr);
}
setAlternatingRowColors(true);
resizeColumnToContents(0);
resizeColumnToContents(1);
if (nearestEvent != -1)
{
selectionModel()->setCurrentIndex(this->model()->index(nearestEvent, 0), QItemSelectionModel::Select);
selectionModel()->select(this->model()->index(nearestEvent, 0), QItemSelectionModel::Select);
selectionModel()->select(this->model()->index(nearestEvent, 1), QItemSelectionModel::Select);
}
}
示例4: showMetaData
void Browser::showMetaData(const QString &t)
{
QSqlRecord rec = connectionWidget->currentDatabase().record(t);
QStandardItemModel *model = new QStandardItemModel(table);
model->insertRows(0, rec.count());
model->insertColumns(0, 7);
model->setHeaderData(0, Qt::Horizontal, "Fieldname");
model->setHeaderData(1, Qt::Horizontal, "Type");
model->setHeaderData(2, Qt::Horizontal, "Length");
model->setHeaderData(3, Qt::Horizontal, "Precision");
model->setHeaderData(4, Qt::Horizontal, "Required");
model->setHeaderData(5, Qt::Horizontal, "AutoValue");
model->setHeaderData(6, Qt::Horizontal, "DefaultValue");
for (int i = 0; i < rec.count(); ++i) {
QSqlField fld = rec.field(i);
model->setData(model->index(i, 0), fld.name());
model->setData(model->index(i, 1), fld.typeID() == -1
? QString(QVariant::typeToName(fld.type()))
: QString("%1 (%2)").arg(QVariant::typeToName(fld.type())).arg(fld.typeID()));
model->setData(model->index(i, 2), fld.length());
model->setData(model->index(i, 3), fld.precision());
model->setData(model->index(i, 4), fld.requiredStatus() == -1 ? QVariant("?")
: QVariant(bool(fld.requiredStatus())));
model->setData(model->index(i, 5), fld.isAutoValue());
model->setData(model->index(i, 6), fld.defaultValue());
}
table->setModel(model);
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
updateActions();
}