当前位置: 首页>>代码示例>>C++>>正文


C++ QAbstractItemModel类代码示例

本文整理汇总了C++中QAbstractItemModel的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractItemModel类的具体用法?C++ QAbstractItemModel怎么用?C++ QAbstractItemModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QAbstractItemModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: model

QModelIndexList
PartitionLabelsView::getIndexesToDraw( const QModelIndex& parent ) const
{
    QModelIndexList list;

    QAbstractItemModel* modl = model();
    if ( !modl )
        return list;

    for ( int row = 0; row < modl->rowCount( parent ); ++row )
    {
        QModelIndex index = modl->index( row, 0, parent );

        //HACK: horrible special casing follows.
        //      To save vertical space, we choose to hide short instances of free space.
        //      Arbitrary limit: 10MB.
        const qint64 maxHiddenB = 10'000'000;
        if ( index.data( PartitionModel::IsFreeSpaceRole ).toBool() &&
             index.data( PartitionModel::SizeRole ).toLongLong() <  maxHiddenB )
            continue;

        list.append( index );
        if ( modl->hasChildren( index ) )
            list.append( getIndexesToDraw( index ) );
    }
    return list;
}
开发者ID:caroling2015,项目名称:calamares,代码行数:27,代码来源:PartitionLabelsView.cpp

示例2: testModel

void tst_QDataWidgetMapper::setData()
{
    QDataWidgetMapper mapper;
    QAbstractItemModel *model = testModel(&mapper);
    mapper.setModel(model);

    QLineEdit edit1;
    QLineEdit edit2;
    QLineEdit edit3;

    mapper.addMapping(&edit1, 0);
    mapper.addMapping(&edit2, 1);
    mapper.addMapping(&edit3, 0, "text");
    mapper.toFirst();
    QCOMPARE(edit1.text(), QString("item 0 0"));
    QCOMPARE(edit2.text(), QString("item 0 1"));
    QCOMPARE(edit3.text(), QString("item 0 0"));

    edit1.setText("new text");

    mapper.submit();
    QCOMPARE(model->data(model->index(0, 0)).toString(), QString("new text"));

    edit3.setText("more text");

    mapper.submit();
    QCOMPARE(model->data(model->index(0, 0)).toString(), QString("more text"));
}
开发者ID:KDE,项目名称:android-qt,代码行数:28,代码来源:tst_qdatawidgetmapper.cpp

示例3: on_acSelect_triggered

void KTracks::on_acSelect_triggered()
{
   QModelIndexList selection = ui->tvTracks->selectionModel()->selectedRows();
   QAbstractItemModel *model = ui->tvTracks->model();

   if (!selection.isEmpty()) {
       QList<QGeoPositionInfo> trackList;
       trackList.clear();
       trackList = sql.selTrack(model->data(model->index(selection.at(0).row(),0)).toInt());

       ui->cpPlot->clearGraphs();
       ui->cpPlot->addGraph();

       QGeoPositionInfo tp;
       QVector<double> x;
       QVector<double> y;
       int cnt = trackList.count();
       x.resize(cnt);
       y.resize(cnt);

       //options
       int pType;
       if (ui->miAltitude->isChecked()) {
           ui->cpPlot->yAxis->setLabel("Altitude [m]");
           pType = 1; }
       if (ui->miDistance->isChecked()) {
           ui->cpPlot->yAxis->setLabel("Distance [m]");
           pType = 2; }
       if (ui->miSpeed->isChecked()) {
           ui->cpPlot->yAxis->setLabel("Speed [m/s]");
           pType = 3; }
       ui->cpPlot->xAxis->setLabel("time [hh:mm:ss]");

       for (int i=0; i<cnt; i++) {
           tp = trackList.value(i);
           x[i] = tp.timestamp().toTime_t();
           switch (pType) {
             case 1: {
               y[i] = tp.coordinate().altitude();
               break; }
             case 2: {
               y[i] = tp.coordinate().distanceTo(trackList.value(0).coordinate());
               break; }
             case 3: {
               y[i] = tp.attribute(QGeoPositionInfo::GroundSpeed);
               break; }
           } //switch
       } //for to

       ui->cpPlot->graph(0)->setData(x,y);
       // set axes ranges, so we see all data:
       ui->cpPlot->xAxis->setRange(x[0],x[cnt-1]);
       qSort(y.begin(), y.end());
       ui->cpPlot->yAxis->setRange(y.first(),y.last());
       //repaint
       ui->cpPlot->replot();

   } //selection.isempty
}
开发者ID:HeikoTietze,项目名称:KTracks,代码行数:59,代码来源:ktracks.cpp

示例4: roleIndexByName

void Element::setRoleValueByName(QString const &roleName, QString const &value)
{
	int roleIndex = roleIndexByName(roleName);
	if (roleIndex < roles::customPropertiesBeginRole)
		return;
	QAbstractItemModel *itemModel = const_cast<QAbstractItemModel*>(mDataIndex.model());
	itemModel->setData(mDataIndex, value, roleIndex);
}
开发者ID:nfrey,项目名称:qreal,代码行数:8,代码来源:uml_element.cpp

示例5: pageRight

void Desktopwidget::pageRight (const QModelIndex &index)
   {
   QAbstractItemModel *model = (QAbstractItemModel *)index.model ();
   int pagenum = model->data (index, Desktopmodel::Role_pagenum).toInt ();
   QVariant v = pagenum + 1;

   model->setData (index, v, Desktopmodel::Role_pagenum);
   }
开发者ID:sglass68,项目名称:paperman,代码行数:8,代码来源:desktopwidget.cpp

示例6: invalidateWidgetPositions

			void PackagesDelegate::invalidateWidgetPositions ()
			{
				QTreeView *view = qobject_cast<QTreeView*> (parent ());
				QAbstractItemModel *model = view->model ();
				for (int i = 0, rows = model->rowCount ();
						i < rows; ++i)
					emit sizeHintChanged (model->index (i, 0));
			}
开发者ID:Apkawa,项目名称:leechcraft,代码行数:8,代码来源:packagesdelegate.cpp

示例7: mapToSource

bool KConcatenateRowsProxyModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    const QModelIndex sourceIndex = mapToSource(index);
    if (!sourceIndex.isValid()) {
        return false;
    }
    QAbstractItemModel *sourceModel = const_cast<QAbstractItemModel *>(sourceIndex.model());
    return sourceModel->setData(sourceIndex, value, role);
}
开发者ID:ske-ableton,项目名称:kitemmodels,代码行数:9,代码来源:kconcatenaterowsproxymodel.cpp

示例8: sourceModel

	QStringList SummaryTagsFilter::GetTagsForIndex (int index) const
	{
		QAbstractItemModel *model = sourceModel ();
		if (!model)
			return QStringList ();

		return model->data (model->index (index, 0),
				RoleTags).toStringList ();
	}
开发者ID:SboichakovDmitriy,项目名称:leechcraft,代码行数:9,代码来源:summarytagsfilter.cpp

示例9: slotCurrentIndexChanged

void ComboFilterItemWidget::slotCurrentIndexChanged(int row)
{
    if(_valueColumn<0)
        return;
    QAbstractItemModel * model = _comboBox->model();   
    QModelIndex index = model->index(row, _valueColumn);    
    const QVariant value = model->data(index, _valueRole);
    emit valueChanged(_filterTag, value);
}
开发者ID:jassuncao,项目名称:myparts,代码行数:9,代码来源:filteritemwidget.cpp

示例10: checkLogItem

void MainWindow::checkLogItem( const QModelIndex& rIndex )
{
    QAbstractItemModel* model = mUI.logListWidget->model();
    if( !model->data( rIndex, Qt::UserRole + 2 ).toBool() || 
        !model->data( rIndex, Qt::UserRole + 3 ).toBool() )
        mUI.logListWidget->item( rIndex.row() )->setHidden( true );
    else
        mUI.logListWidget->item( rIndex.row() )->setHidden( false );
}
开发者ID:Gohla,项目名称:Diversia,代码行数:9,代码来源:MainWindow.cpp

示例11: flags

Qt::ItemFlags TodoNode::flags(int column) const
{
    if (m_rowSourceIndex.isValid()) {
        QAbstractItemModel *model = const_cast<QAbstractItemModel*>(m_rowSourceIndex.model());
        return model->flags(m_rowSourceIndex.sibling(m_rowSourceIndex.row(), column));
    } else {
        return m_flags;
    }
}
开发者ID:sandsmark,项目名称:zanshin,代码行数:9,代码来源:todonode.cpp

示例12:

void MainWindow::on_pushButton_5_clicked()
{
    int row= ui->tableView->currentIndex().row();
    QAbstractItemModel *model = ui->tableView->model ();
    QModelIndex index = model->index(row,0);//选中行第一列的内容
    QVariant data = model->data(index);

    ui->le_ExeFile->setText(data.toString());
}
开发者ID:camark,项目名称:InnoSetup-Script-Generator,代码行数:9,代码来源:mainwindow.cpp

示例13: slotImportAll

void ThumbnailPage::slotImportAll()
{
    QModelIndexList list;
    QAbstractItemModel* model = d->mThumbnailView->model();
    for (int row = model->rowCount() - 1; row >= 0; --row) {
        list << model->index(row, 0);
    }
    importList(list);
}
开发者ID:KDE,项目名称:gwenview,代码行数:9,代码来源:thumbnailpage.cpp

示例14: setRowData

void TodoNode::setRowData(const QVariant &value, int role)
{
    if (m_rowSourceIndex.isValid()) {
        QAbstractItemModel *model = const_cast<QAbstractItemModel*>(m_rowSourceIndex.model());
        model->setData(m_rowSourceIndex, value, role);
    } else {
        m_data[QPair<int, int>(-1, role)] = value;
    }
}
开发者ID:sandsmark,项目名称:zanshin,代码行数:9,代码来源:todonode.cpp

示例15: removeRow

void DefectsEditor::removeRow()
{
    QModelIndex index = tableView->selectionModel()->currentIndex();
    QAbstractItemModel* model = tableView->model();
    if (model->removeRows(index.row(), 1, index.parent())) {
        //updateActions();
        updateData(index, index);
    }
}
开发者ID:Debilski,项目名称:Wellenprogramm,代码行数:9,代码来源:defects_editor.cpp


注:本文中的QAbstractItemModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。