本文整理汇总了C++中QStandardItem::column方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::column方法的具体用法?C++ QStandardItem::column怎么用?C++ QStandardItem::column使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::column方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSetChild
void tst_QStandardItem::getSetChild()
{
QFETCH(int, rows);
QFETCH(int, columns);
QFETCH(int, row);
QFETCH(int, column);
QStandardItem item(rows, columns);
bool shouldHaveChildren = (rows > 0) && (columns > 0);
QCOMPARE(item.hasChildren(), shouldHaveChildren);
QCOMPARE(item.child(row, column), static_cast<QStandardItem*>(0));
QStandardItem *child = new QStandardItem;
item.setChild(row, column, child);
if ((row >= 0) && (column >= 0)) {
QCOMPARE(item.rowCount(), qMax(rows, row + 1));
QCOMPARE(item.columnCount(), qMax(columns, column + 1));
QCOMPARE(item.child(row, column), child);
QCOMPARE(child->row(), row);
QCOMPARE(child->column(), column);
QStandardItem *anotherChild = new QStandardItem;
item.setChild(row, column, anotherChild);
QCOMPARE(item.child(row, column), anotherChild);
QCOMPARE(anotherChild->row(), row);
QCOMPARE(anotherChild->column(), column);
item.setChild(row, column, 0);
} else {
delete child;
}
QCOMPARE(item.child(row, column), static_cast<QStandardItem*>(0));
}
示例2: data
virtual bool operator<(const QStandardItem &other) const
{
const QVariant l = data(Qt::DisplayRole), r = other.data(Qt::DisplayRole);
if (column() == other.column())
{
return l.toDouble() < r.toDouble();
}
return QStandardItem::operator<(other);
}
示例3: column
bool LedgerItem::operator<(const QStandardItem &other) const
{
if( model() && other.model() && model()==other.model() &&
column() == Ledger::COL_DESCRIP && other.column() == Ledger::COL_DESCRIP )
{
QString a, b;
a = data(model()->sortRole()).toString();
b = other.data(other.model()->sortRole()).toString();
return a.localeAwareCompare(b)<0;
}
return QStandardItem::operator <(other);
}
示例4: QStandardItem
QStandardItem *
StandardItemHelper::appendRow( QStandardItem * parent, const char * label, const QVariant& qv )
{
QStandardItem * item = new QStandardItem( label );
item->setEditable( false );
if ( parent ) {
parent->appendRow( item );
QStandardItemModel& model = *item->model();
int row = item->row();
int col = item->column();
model.setData( model.index( row, col + 1, parent->index() ), qv );
}
return item;
}
示例5: helpEvent
/*
* Called every time user positions mouse over package's treeview items
*/
bool TreeViewPackagesItemDelegate::helpEvent ( QHelpEvent *event, QAbstractItemView*,
const QStyleOptionViewItem&, const QModelIndex &index )
{
if (this->parent()->objectName() == "tvPackages")
{
QTreeView* tvPackages = qobject_cast<QTreeView*>(this->parent());
QSortFilterProxyModel *sfp = qobject_cast<QSortFilterProxyModel*>(tvPackages->model());
QStandardItemModel *sim = qobject_cast<QStandardItemModel*>(sfp->sourceModel());
if (sim->rowCount() == 0) return false;
QModelIndex ind = sfp->mapToSource(index);
QStandardItem *si = sim->itemFromIndex(ind);
if (si)
{
//If the user's mouse is not positioned above the name column, let's give him a little help...
if (si->column() != ctn_PACKAGE_NAME_COLUMN)
{
QModelIndex miName = sim->index(si->row(), ctn_PACKAGE_NAME_COLUMN);
si = sim->itemFromIndex(miName);
}
QPoint p;
gPoint = tvPackages->mapToGlobal(event->pos());
QFuture<QString> f;
disconnect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip()));
f = QtConcurrent::run(showPackageInfo, si->text());
g_fwToolTip.setFuture(f);
connect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip()));
}
else return false;
}
else if (this->parent()->objectName() == "tvTransaction")
{
QTreeView* tvTransaction = qobject_cast<QTreeView*>(this->parent());
QStandardItemModel *sim = qobject_cast<QStandardItemModel*>(tvTransaction->model());
if (sim->rowCount() == 0) return false;
QStandardItem *si = sim->itemFromIndex(index);
if (si)
{
//If it's really a package in the Transaction treeview...
QString pkgName=si->text();
//We have to separate Repository from Package Name, first
int slash = pkgName.indexOf("/");
if (slash != -1)
{
pkgName = pkgName.mid(slash+1);
}
if (si->icon().pixmap(22, 22).toImage() ==
IconHelper::getIconInstallItem().pixmap(22, 22).toImage() ||
si->icon().pixmap(22, 22).toImage() ==
IconHelper::getIconRemoveItem().pixmap(22, 22).toImage())
{
QStandardItemModel *modelPackages = MainWindow::returnMainWindow()->getModelPackages();
QList<QStandardItem*> foundItems =
modelPackages->findItems(pkgName, Qt::MatchExactly, ctn_PACKAGE_NAME_COLUMN);
if (foundItems.count() > 0)
{
QStandardItem *siFound = foundItems.at(0);
QPoint p;
gPoint = tvTransaction->mapToGlobal(event->pos());
QFuture<QString> f;
disconnect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip()));
f = QtConcurrent::run(showPackageInfo, siFound->text());
g_fwToolTip.setFuture(f);
connect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip()));
}
}
else
{
QToolTip::hideText();
}
}
}
return true;
}
示例6: tableview_generations_clicked
void MainWindow::tableview_generations_clicked(QModelIndex index)
{
QStandardItem *item = _modelGenerations->itemFromIndex(index);
item->column();
qDebug() << "clicked signal";
qDebug() << item->text();
QDomDocument doc;
QString filename = _strLogDir + "/" + item->text();
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
{ qDebug() << "Fail to open file...";
return;
}
if (!doc.setContent(&file)) {
qDebug() << "Fail to populize domdocument...";
file.close();
return;
}
file.close();
// clear old model
_modelIndividuals->clear();
_genos.clear();
// initialize view header
QStringList strList;
strList.append("Fitness");
strList.append("Size");
strList.append("Depth");
//strList.append("Genotype");
_modelIndividuals->setHorizontalHeaderLabels(strList);
// get individuals
QDomNodeList individuals = doc.elementsByTagName("Individual");
// for each individual get fitness value and genotype
for(int i = 0; i < individuals.size(); i++)
{
QDomElement individual = individuals.at(i).toElement();
int indi_size = individual.attribute("size").toInt();
QDomElement elem = individual.firstChildElement();
QString fitness = elem.text();
for (int j = 0; j < indi_size; j++)
{
elem = elem.nextSiblingElement();
// add individual index
QList<QStandardItem *> items;
items.append(new QStandardItem( fitness ));
items.append(new QStandardItem( elem.attribute("size") ));
items.append(new QStandardItem( elem.attribute("depth") ));
QString str;
QTextStream stream(&str);
stream << elem.firstChildElement();
stream.flush();
//items.append(new QStandardItem( str.trimmed() ));
_genos.append(str);
_modelIndividuals->appendRow(items);
}
}
ui->tableView_Individuals->resizeColumnsToContents();
ui->tableView_Individuals->sortByColumn(0);
}