本文整理汇总了C++中QAbstractItemModel::rowCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractItemModel::rowCount方法的具体用法?C++ QAbstractItemModel::rowCount怎么用?C++ QAbstractItemModel::rowCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractItemModel
的用法示例。
在下文中一共展示了QAbstractItemModel::rowCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: accept
void EditSolutionDialog::accept()
{
QVariant bw = ui->bw->property("wine");
QModelIndexList l = mWineModel->match(mWineModel->index(0, 0), Qt::DisplayRole, bw, -1, Qt::MatchFixedString);
bw = l.first().data(PackageModel::IdRole);
QVariant aw = ui->aw->property("wine");
l = mWineModel->match(mWineModel->index(0, 0), Qt::DisplayRole, aw, -1, Qt::MatchFixedString);
aw = l.first().data(PackageModel::IdRole);
SolutionModel::IntList bp;
QAbstractItemModel *bpm = ui->bp->model();
for (int i = 0, count = bpm->rowCount(); i < count; ++i)
bp.append(bpm->index(i, 0).data(PackageModel::IdRole).toInt());
SolutionModel::IntList ap;
QAbstractItemModel *apm = ui->ap->model();
for (int i = 0, count = apm->rowCount(); i < count; ++i)
ap.append(apm->index(i, 0).data(PackageModel::IdRole).toInt());
QModelIndex index = mModel->index(mRow, 0);
QMap<int, QVariant> data;
data.insert(SolutionModel::BWRole, bw);
data.insert(SolutionModel::AWRole, aw);
data.insert(SolutionModel::BPRole, QVariant::fromValue(bp));
data.insert(SolutionModel::APRole, QVariant::fromValue(ap));
QSortFilterProxyModel *sm = static_cast<QSortFilterProxyModel *>(mModel);
sm->sourceModel()->setItemData(sm->mapToSource(index), data);
QDialog::accept();
}
示例2: OnConvertButtonClicked
void MainWindow::OnConvertButtonClicked()
{
QAbstractItemModel *model = ui->listView->model();
if (!model || model->rowCount() == 0)
{
return;
}
while (model->rowCount())
{
QString pvrName = model->data(model->index(0, 0)).toString();
QString pngName = pvrName;
pngName.replace(".pvr", ".png", Qt::CaseInsensitive);
unsigned char* data;
unsigned long int size;
PVRTHeader header;
int ret = LoadPVRFromFile(pvrName.toUtf8().data(), &data, &size, &header);
if (ret)
{
QFile file(pngName);
file.open(QIODevice::WriteOnly);
QImage image(data, header.width, header.height, QImage::Format_RGBA8888);
QPixmap pixmap = QPixmap::fromImage(image);
pixmap.save(&file, "PNG");
free(data);
}
model->removeRow(0);
}
ui->statusBar->showMessage("Done!");
}
示例3: clonningTest
void CBBaseProviderTestSet::clonningTest(){
QAbstractItemModel * listModel = (QAbstractItemModel *)m_current_node->listModel();
int recordCount = listModel->rowCount();
m_current_node->selectItemWithIndex(2);
QVariantMap default_item = m_current_node->selectedItem();
m_current_node->cloneItem();
QVariantMap clonned_item = m_current_node->selectedItem();
for (auto iter: default_item.keys()){
if (iter == "id"){
QVERIFY(clonned_item[iter]!=default_item[iter]);
}
else{
QVERIFY(clonned_item[iter]==default_item[iter]);
}
}
clonned_item["nominal"]=QVariant("Test insert");
clonned_item["firstYear"]=QVariant(1000);
m_current_node->applyChanges(clonned_item);
// check that selected item was not changed after appliing changes
QVariantMap clonned_item_after_saving = m_current_node->selectedItem();
QVERIFY(clonned_item["id"]==clonned_item_after_saving["id"]);
// check that we have recordCount + 1
QCOMPARE(recordCount+1,listModel->rowCount());
}
示例4: getPreIndex
QModelIndex FindDialog::getPreIndex(QModelIndex index)
{
QAbstractItemModel *model = m_parent->ui.tree_view->model();
assert(NULL != model);
// 根节点的前一个是最后一个节点
if (!index.isValid())
{
QModelIndex current = model->index(0,0,QModelIndex());
while (model->rowCount(current) > 0)
current = current.child(model->rowCount(current) - 1, 0);
return current;
}
QModelIndex parent = index.parent();
if (!parent.isValid())
return QModelIndex(); // 根
int row = index.row();
if (row == 0)
return parent;
QModelIndex current = parent.child(row - 1, 0);
while (model->rowCount(current) > 0)
current = current.child(model->rowCount(current) - 1, 0);
return current;
}
示例5: on_borrowAddBtn_clicked
void AdminDialog::on_borrowAddBtn_clicked()
{
QAbstractItemModel *model = ui->tv3->model();
for(int i=0;i<model->rowCount();i++)
{
QModelIndex index = ui->tv3->model()->index(i,0);
QString boid = ui->tv3->model()->data(index).toString();
QSqlQuery query(Tool::getInstance()->getDb());
query.exec("update borrow set overbor=overbor+1 where boid="+boid);
}
if(model->rowCount()>0){
QMessageBox::about(NULL,"提示","增加续借次数成功!");
initBorrowTableView();
}
}
示例6: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
MyTest *t = new MyTest();
QImage i("/home/jasuarez/MyDocs/12020001.jpg");
t->connect(t->recognizer, SIGNAL(facesDetected(QString,QImage,QSize,QList<QRect>)), t, SLOT(onFacesDetected(QString,QImage,QSize,QList<QRect>)));
t->connect(t->recognizer, SIGNAL(facesRecognized(QString,QImage,QList<XQFaceRegion>)), t, SLOT(onFacesRecognized(QString,QImage,QList<XQFaceRegion>)));
//t->recognizer->detectFaces("t1", i);
t->recognizer->processFaces("urn:uuid:15fb1a3d-cfe7-ebb7-a110-bdc0c6968c8f", i);
return a.exec();
XQFaceGroup group = t->db->faceGroup("Jota");
QAbstractItemModel *m = group.faces();
int s = m->rowCount();
qDebug() << s;
QAbstractItemModel *m2 = t->db->faceGroups(XQFaceDatabase::UnnamedGroup);
QString f = m2->index(0,0,QModelIndex()).data().toString();
qDebug() << f;
group = t->db->faceGroup(f);
qDebug() << group.faceId();
m = group.faces();
f = m->index(0,0,QModelIndex()).data().toString();
XQFaceRegion region = group.faceRegion(f);
qDebug() << region.sourceId();
qDebug() << region.faceIds().size();
qDebug() << region.faceIds().at(0);
s = m2->rowCount();
qDebug() << s;
return a.exec();
}
示例7: saveItems
bool ItemSyncSaver::saveItems(const QString &tabName, const QAbstractItemModel &model, QIODevice *file)
{
// Don't save items if path is empty.
if (!m_watcher) {
writeConfiguration(file, QStringList());
return true;
}
const QString path = m_watcher->path();
QStringList savedFiles;
if ( !m_watcher->isValid() ) {
log( tr("Failed to synchronize tab \"%1\" with directory \"%2\"!")
.arg(tabName, path),
LogError );
return false;
}
QDir dir(path);
for (int row = 0; row < model.rowCount(); ++row) {
const QModelIndex index = model.index(row, 0);
const QVariantMap itemData = index.data(contentType::data).toMap();
const QVariantMap mimeToExtension = itemData.value(mimeExtensionMap).toMap();
const QString baseName = FileWatcher::getBaseName(index);
const QString filePath = dir.absoluteFilePath(baseName);
for (const auto &ext : mimeToExtension)
savedFiles.prepend( filePath + ext.toString() );
}
writeConfiguration(file, savedFiles);
return true;
}
示例8: findNetworkObject
QModelIndex ComputerManager::findNetworkObject( const NetworkObject::Uid& networkObjectUid, const QModelIndex& parent )
{
QAbstractItemModel* model = networkObjectModel();
int rows = model->rowCount( parent );
for( int i = 0; i < rows; ++i )
{
QModelIndex entryIndex = model->index( i, 0, parent );
auto objectType = static_cast<NetworkObject::Type>( model->data( entryIndex, NetworkObjectModel::TypeRole ).toInt() );
if( objectType == NetworkObject::Group )
{
QModelIndex index = findNetworkObject( networkObjectUid, entryIndex );
if( index.isValid() )
{
return index;
}
}
else if( objectType == NetworkObject::Host )
{
if( model->data( entryIndex, NetworkObjectModel::UidRole ).toUuid() == networkObjectUid )
{
return entryIndex;
}
}
}
return QModelIndex();
}
示例9: get_switchboard_incoming_calls_infos
QVariantMap RemoteControl::get_switchboard_incoming_calls_infos()
{
QVariantMap result;
Switchboard *xlet = this->get_xlet<Switchboard>("switchboard");
QueueEntriesView * incoming = xlet->ui.incomingCallsView;
this->assert(incoming != NULL, "widget for incoming calls is null");
QAbstractItemModel *model = incoming->model();
QVariantList list;
for (int row = 0; row < model->rowCount(); row++) {
QVariantMap incoming;
incoming["position"] = this->getValueInModel(model, row, QueueEntriesModel::POSITION);
incoming["cid_name"] = this->getValueInModel(model, row, QueueEntriesModel::NAME);
incoming["cid_num"] = this->getValueInModel(model, row, QueueEntriesModel::NUMBER);
incoming["time"] = this->getValueInModel(model, row, QueueEntriesModel::TIME);
incoming["unique_id"] = this->getValueInModel(model, row, QueueEntriesModel::UNIQUE_ID);
list.append(incoming);
}
result["incoming_calls"] = list;
return result;
}
示例10: colorSchemeAnimationUpdate
void EditProfileDialog::colorSchemeAnimationUpdate()
{
QAbstractItemModel* model = _ui->colorSchemeList->model();
for ( int i = model->rowCount() ; i >= 0 ; i-- )
_ui->colorSchemeList->update( model->index(i,0) );
}
示例11: copy
void ResultsOutput::copy()
{
if (DEBUG)
qDebug("ResultsOutput::copy() entered");
QClipboard *clipboard = QApplication::clipboard();
QAbstractItemModel *model = _table->model();
QByteArray bytes;
for (int i = 0; i < model->rowCount(); i++)
{
for (int j = 0; j < model->columnCount(); j++)
{
if (j)
bytes += ",";
bytes += "\"" +
model->data(model->index(i, j)).toString().replace("\"", "\"\"") +
"\"";
}
bytes += "\n";
}
clipboard->setText(bytes);
if (DEBUG)
qDebug("ResultsOutput::copy() returning with bytes %s", bytes.data());
}
示例12: addEntry
void EmoticonViewer::addEntry()
{
QAbstractItemModel *model = _ui->listView->model();
int row = model->rowCount();
model->insertRow(row);
_ui->listView->edit(model->index(row, 0));
}
示例13: data
QVariant TaskContextMenuModel::data(const QModelIndex &index, int role) const
{
if (index.row() < 0 || index.row() >= rowCount(QModelIndex()))
return QVariant();
if (index.row() < rowOffset())
return staticData(static_cast<OptionType>(index.row()), role);
const int tagRow = index.row() - rowOffset();
QAbstractItemModel *tagModel = m_task->checkableTagModel();
if (tagRow < 0 || tagRow >= tagModel->rowCount()) {
qWarning() << "TaskContextMenuModel: invalid index" << tagRow;
return QVariant();
}
QModelIndex tagIndex = tagModel->index(tagRow, 0);
switch (role) {
case TextRole:
return tagIndex.data(CheckableTagModel::ItemTextRole);
case IconRole:
return "";
case CheckableRole:
return true;
case DismissRole:
return false;
case Qt::CheckStateRole:
return tagIndex.data(Qt::CheckStateRole);
}
return QVariant();
}
示例14: sizeHint
QSizeF HbTumbleViewItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
HB_SDD(const HbAbstractViewItem);
static qreal height=0;
QSizeF sh=HbListViewItem::sizeHint(which,constraint);
if(which == Qt::PreferredSize && sh.height()<=0) {
//TODO:remove this check once refresh issue in DTP is solved on removeRows/insertRows
if(height<=0) {
//Let's create a temporary item and take the height for the size hint
HbAbstractViewItem *tempitem = sd->mPrototype->createItem();
if(sd->mItemView) {
QAbstractItemModel *model = sd->mItemView->model();
if(model) {
int rowCount=model->rowCount();
QModelIndex ind=model->index(rowCount,0);
if(ind.isValid()) {
tempitem->setModelIndex(ind);
}
}
}
//call polish
QEvent polishEvent(QEvent::Polish);
QCoreApplication::sendEvent(const_cast<HbAbstractViewItem *>(tempitem), &polishEvent);
height=tempitem->effectiveSizeHint(which,constraint).height();
delete tempitem;
}
return QSizeF(sh.width(),height);
}
return sh;
}
示例15: findRoomOfComputer
QString ComputerManager::findRoomOfComputer( const QStringList& hostNames, const QList<QHostAddress>& hostAddresses, const QModelIndex& parent )
{
QAbstractItemModel* model = networkObjectModel();
int rows = model->rowCount( parent );
for( int i = 0; i < rows; ++i )
{
QModelIndex entryIndex = model->index( i, 0, parent );
auto objectType = static_cast<NetworkObject::Type>( model->data( entryIndex, NetworkObjectModel::TypeRole ).toInt() );
if( objectType == NetworkObject::Group )
{
QString room = findRoomOfComputer( hostNames, hostAddresses, entryIndex );
if( room.isEmpty() == false )
{
return room;
}
}
else if( objectType == NetworkObject::Host )
{
QString currentHost = model->data( entryIndex, NetworkObjectModel::HostAddressRole ).toString().toLower();
QHostAddress currentHostAddress;
if( hostNames.contains( currentHost ) ||
( currentHostAddress.setAddress( currentHost ) && hostAddresses.contains( currentHostAddress ) ) )
{
return model->data( parent, NetworkObjectModel::NameRole ).toString();
}
}
}
return QString();
}