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


C++ QAbstractItemModel::setHeaderData方法代码示例

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


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

示例1: setupModel

void LogDetailWidget::setupModel()
{
	QAbstractItemModel *model = pieChart->model();

	model->setHeaderData(0, Qt::Horizontal, tr("Label"));
    model->setHeaderData(1, Qt::Horizontal, tr("Quantity"));

	QString colors[] = {"#ff0000", "#00ff00", "#0000ff","#ffff00", "#ff00ff", "#00ffff", "#000000", "#ffffff", "#777777", "#222222", "#aaaaaa"};

	int i=0;
	for(hash_map<string, double>::iterator it = logMan.process_stat.begin() ; it != logMan.process_stat.end(); it++)
	{
		string process = it->first;
		double duration = it->second;

		model->insertRow(i);
		model->setData(model->index(i, 0), QString::fromStdString(process));
		model->setData(model->index(i, 1), duration);

		model->setData(model->index(i, 0, QModelIndex()),
                           QColor(colors[i]), Qt::DecorationRole);
		i++;
	}

}
开发者ID:baolingfeng,项目名称:HCICollectTool,代码行数:25,代码来源:logdetailwidget.cpp

示例2: InitFields

void GameAssetTreeWidget::InitFields()
{
	////////////////////////////////////////
	//Game Assets Tree Type
	AEQTUserTemplateData<AEQTObjType>* gameAssetsTreeType = new AEQTUserTemplateData<AEQTObjType>(AEQTObjType::GameAssetsTree);
	this->setUserData(AE_QT_USER_DATA_OBJ_TYPE_SLOT, gameAssetsTreeType);

	///////////////////////////////////////////
	//Set preferred indentation
	this->setIndentation(AE_QT_TREE_INDENTATION);

	///////////////////////////////////////////
	//Set Animation
	this->setAnimated(true);

	///////////////////////////////////////////
	//Set Alternating Row Colors
	this->setAlternatingRowColors(false);

	///////////////////////////////////////////
	//Set number of columns and their names
	this->setColumnCount(2);

	QAbstractItemModel* itemModel = this->model();

	itemModel->setHeaderData(0, Qt::Orientation::Horizontal, "Property", Qt::ItemDataRole::DisplayRole);
	itemModel->setHeaderData(1, Qt::Orientation::Horizontal, "Value", Qt::ItemDataRole::DisplayRole);

	///////////////////////////////////////////
	//Finish
	m_IsReady = true;
}
开发者ID:dtbinh,项目名称:Arenal-Engine,代码行数:32,代码来源:GameAssetTreeWidget.cpp

示例3: insertChild

void MainWindow::insertChild()
{
    QModelIndex index = view->selectionModel()->currentIndex();
    QAbstractItemModel *model = view->model();

    if (model->columnCount(index) == 0) {
        if (!model->insertColumn(0, index))
            return;
    }

    if (!model->insertRow(0, index))
        return;

    for (int column = 0; column < model->columnCount(index); ++column) {
        QModelIndex child = model->index(0, column, index);
        model->setData(child, QVariant("[No data]"), Qt::EditRole);
        if (!model->headerData(column, Qt::Horizontal).isValid())
            model->setHeaderData(column, Qt::Horizontal, QVariant("[No header]"),
                                 Qt::EditRole);
    }

    view->selectionModel()->setCurrentIndex(model->index(0, 0, index),
                                            QItemSelectionModel::ClearAndSelect);
    updateActions();
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:25,代码来源:mainwindow.cpp

示例4: classifyAction

void LogDetailWidget::classifyAction()
{
	QAbstractItemModel *model = new QStandardItemModel(0, 6, this);
	ui.aaView->setModel(model);

	int k = 0;
	model->setHeaderData(k++, Qt::Horizontal, tr("Timestamp"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Application"));
	model->setHeaderData(k++, Qt::Horizontal, tr("GUI Component"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Control Name"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Control Type"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Control Value"));

	string eclipseStatus = "normal"; //normal edit; run or debug configuration; debug model; 
	int temp;
	int num = 0;
	for(int i=0; i<logMan.events.size(); i++)
	{
		LogEvent e = logMan.events[i];
		if(!e.isHasAcc) continue;

		model->insertRow(num);

		k = 0;
		model->setData(model->index(num,k++), QString::fromStdString(e.timestamp));
		model->setData(model->index(num,k++), QString::fromStdString(e.processName));
		
		if(e.acc.type == "menu item" || e.acc.type == "tab item" 
			|| e.acc.parent_name == "Desktop" || e.acc.parent_name == "%trimmedwindow.label.eclipseSDK")
		{
			model->setData(model->index(num,k++), QString::fromStdString(e.acc.name));
		}
		else
		{
			model->setData(model->index(num,k++), QString::fromStdString(e.acc.parent_name));
		}
		
		model->setData(model->index(num,k++), QString::fromStdString(e.acc.name));
		model->setData(model->index(num,k++), QString::fromStdString(e.acc.type));
		model->setData(model->index(num,k++), QString::fromStdString(e.acc.value));
		num++;

	}
}
开发者ID:baolingfeng,项目名称:HCICollectTool,代码行数:44,代码来源:logdetailwidget.cpp

示例5: initComplexModel

QAbstractItemModel * radDataWidget :: initComplexModel (const complex<double> * zVec, int n)
{
    if (!zVec || n==0)
        return 0;

    QAbstractItemModel * cModel = new QStandardItemModel (n, 2);
    cModel->setHeaderData (0, Qt::Horizontal, tr("Real component"), Qt::DisplayRole);
    cModel->setHeaderData (1, Qt::Horizontal, tr("Image component"), Qt::DisplayRole);
    for (int i=0; i<n; i++)
    {
        double r = real(zVec[i]);
        double im = imag(zVec[i]);
        QModelIndex cRInd = cModel->index (i, 0);
        cModel->setData (cRInd, QString::number (r, 'f', 16), Qt::DisplayRole);
        QModelIndex cImInd = cModel->index (i, 1);
        cModel->setData (cImInd, QString::number (im, 'f', 16), Qt::DisplayRole);
    }

    return cModel;
}
开发者ID:YuriyRusinov,项目名称:radius,代码行数:20,代码来源:radDataWidget.cpp

示例6: insertColumn

bool MainWindow::insertColumn(const QModelIndex &parent)
{
    QAbstractItemModel *model = view->model();
    int column = view->selectionModel()->currentIndex().column();

    // Insert a column in the parent item.
    bool changed = model->insertColumn(column + 1, parent);
    if (changed)
        model->setHeaderData(column + 1, Qt::Horizontal, QVariant("[No header]"), Qt::EditRole);

    updateActions();

    return changed;
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:14,代码来源:mainwindow.cpp

示例7: funcKeyInput

void LogDetailWidget::funcKeyInput()
{
	QAbstractItemModel *model = new QStandardItemModel(0, 4, this);
	ui.funcKeyView->setModel(model);

	int k = 0;
	model->setHeaderData(k++, Qt::Horizontal, tr("Timestamp"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Keys"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Window Name"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Process Name"));

	for(int i=0 ;i<logMan.keyEvents.size(); i++)
	{
		string keystr = logMan.keysToString(logMan.keyEvents[i]);

		model->insertRow(i);
		k=0;
		model->setData(model->index(i,k++), QString::fromStdString(logMan.keyEvents[i][0].timestamp));
		model->setData(model->index(i,k++), QString::fromStdString(keystr));
		model->setData(model->index(i,k++), QString::fromStdString(logMan.keyEvents[i][0].windowName));
		model->setData(model->index(i,k++), QString::fromStdString(logMan.keyEvents[i][0].processName));
	}
}
开发者ID:baolingfeng,项目名称:HCICollectTool,代码行数:23,代码来源:logdetailwidget.cpp

示例8: InitFields

void GameObjectTreeWidget::InitFields()
{
	////////////////////////////////////////
	//Game Objects Tree Type
	AEQTUserTemplateData<AEQTObjType>* GameObjectsTreeType = new AEQTUserTemplateData<AEQTObjType>(AEQTObjType::GameObjectsTree);
	this->setUserData(AE_QT_USER_DATA_OBJ_TYPE_SLOT, GameObjectsTreeType);

	///////////////////////////////////////////
	//Set preferred indentation
	this->setIndentation(AE_QT_TREE_INDENTATION);

	///////////////////////////////////////////
	//Set Drag Mode
	this->setDragDropMode(DragDropMode::InternalMove);

	///////////////////////////////////////////
	//Set Animation
	this->setAnimated(true);

	///////////////////////////////////////////
	//Set Alternating Row Colors
	this->setAlternatingRowColors(false);

	///////////////////////////////////////////
	//Set number of columns and their names
	this->setColumnCount(1);

	QAbstractItemModel* itemModel = this->model();

	itemModel->setHeaderData(0, Qt::Orientation::Horizontal, "Game Objects", Qt::ItemDataRole::DisplayRole);

	///////////////////////////////////////////
	//Connect to Signals
	connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(GameObjectSelectionChanged()));

	///////////////////////////////////////////
	//Finish
	m_IsReady = true;
}
开发者ID:dtbinh,项目名称:Arenal-Engine,代码行数:39,代码来源:GameObjectTreeWidget.cpp

示例9: insertChild

void MetaEditor::insertChild(QString code, QString contents)
{
    QModelIndex index = view->selectionModel()->currentIndex();
    QAbstractItemModel *model = view->model();

    // restrict children to be a grandchild of the root item
    // and make sure you are in column 0 when inserting a child
    if (index.parent() != QModelIndex()) {
        index = index.parent();
    }
    int row = index.row();
    index = index.sibling(row,0);

    if (model->columnCount(index) == 0) {
        if (!model->insertColumn(0, index))
            return;
    }

    if (!model->insertRow(0, index))
        return;

    QModelIndex child = model->index(0, 0, index);
    model->setData(child, QVariant(code), Qt::EditRole);
    for (int column = 1; column < model->columnCount(index); ++column) {
        QModelIndex child = model->index(0, column, index);
        if (!contents.isEmpty()) {
            model->setData(child, QVariant(contents), Qt::EditRole);
        } else {
            model->setData(child, QVariant(tr("[Place value here]")), Qt::EditRole);
        }
        if (!model->headerData(column, Qt::Horizontal).isValid())
            model->setHeaderData(column, Qt::Horizontal, QVariant("[No header]"), Qt::EditRole);
    }

    view->selectionModel()->setCurrentIndex(model->index(0, 0, index),
                                            QItemSelectionModel::ClearAndSelect);
    updateActions();
}
开发者ID:Sigil-Ebook,项目名称:Sigil,代码行数:38,代码来源:MetaEditor.cpp

示例10:

void
setSymbolicColumnNames(QAbstractItemModel &model,
                       QStringList const &names) {
    for (auto column = 0, numColumns = std::min(model.columnCount(), names.count()); column < numColumns; ++column)
        model.setHeaderData(column, Qt::Horizontal, names[column], Util::SymbolicNameRole);
}
开发者ID:rootslinux,项目名称:mkvtoolnix,代码行数:6,代码来源:model.cpp

示例11: copyPaste

void LogDetailWidget::copyPaste()
{
	QAbstractItemModel *model = new QStandardItemModel(0, 7, this);
	ui.cpView->setModel(model);

	int k = 0;
	model->setHeaderData(k++, Qt::Horizontal, tr("Timestamp"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Copy"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Window Name"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Process Name"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Paste"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Window Name"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Process Name"));

	int i, j;
	i = j = 0;
	int num = 0;
	while(i<logMan.copy_events.size() || j < logMan.paste_events.size())
	{
		string type = "";
		string timestamp = "";
		string copyText = "";
		string cwindow = "";
		string cprocess = "";
		string pasteText = "";
		string pwindow = "";
		string pprocess = "";
		if(i>=logMan.copy_events.size())
		{
			timestamp = logMan.paste_events[j].timestamp;
			pasteText = logMan.paste_events[j].method;
			pwindow = logMan.paste_events[j].windowName;
			pprocess= logMan.paste_events[j].processName;
			j++;
		}
		else if(j>=logMan.paste_events.size())
		{
			timestamp = logMan.copy_events[i].timestamp;
			copyText = logMan.copy_events[i].text;
			cwindow = logMan.copy_events[i].windowName;
			cprocess= logMan.copy_events[i].processName;
			i++;
		}
		else
		{
			string t1 = logMan.copy_events[i].timestamp;
			string t2 = logMan.paste_events[j].timestamp;
			double interval = GetTimeDifference(toSystemTime(t1), toSystemTime(t2));
			if(interval<0)
			{
				timestamp = logMan.paste_events[j].timestamp;
				pasteText = logMan.paste_events[j].method;
				pwindow = logMan.paste_events[j].windowName;
				pprocess= logMan.paste_events[j].processName;
				j++;	
			}
			else
			{
				timestamp = logMan.copy_events[i].timestamp;
				copyText = logMan.copy_events[i].text;
				cwindow = logMan.copy_events[i].windowName;
				cprocess= logMan.copy_events[i].processName;
				i++;
			}
		}
		k=0;
		model->insertRow(num);
		model->setData(model->index(num,k++), QString::fromStdString(timestamp));
		model->setData(model->index(num,k++), QString::fromStdString(copyText));
		model->setData(model->index(num,k++), QString::fromStdString(cwindow));
		model->setData(model->index(num,k++), QString::fromStdString(cprocess));
		model->setData(model->index(num,k++), QString::fromStdString(pasteText));
		model->setData(model->index(num,k++), QString::fromStdString(pwindow));
		model->setData(model->index(num,k++), QString::fromStdString(pprocess));
		num++;
	}
}
开发者ID:baolingfeng,项目名称:HCICollectTool,代码行数:77,代码来源:logdetailwidget.cpp

示例12: fContData


//.........这里部分代码省略.........
        double * stc2 = new double [2*nd];
        double * stc2abs = new double [nd];
        for (int ii=0; ii<nd; ii++)
        {
            int ind = ii;//(ii==0 ? nd-1 : ii-1);
            stc2[2*ii] = real (xfft[ind])/nd;//stc3[i]);
            stc2[2*ii+1] = imag (xfft[ind])/nd;
//            stc2Op << stc2[2*i] << " " << stc2[2*i+1] << endl;
            stc2abs[ii] = sqrt (stc2[2*ii]*stc2[2*ii] + stc2[2*ii+1]*stc2[2*ii+1]);
            if (i0==0)
                maxval = qMax (maxval, stc2abs[ii]);
            double gray (i0==0 ? 0.0 : (stc2abs[ii]/maxval)*20000);
            vals [(i0+1)%50+ii] = gray;
            if ((i0+1)/50*50 == i0+1)
            {
                double gray_ave (0.0);
                for (int iii=0; iii<50; iii++)
                    gray_ave += vals [iii];
                uint val = (uint)(256*(gray_ave/5.0e1));

                QRgb v = qRgb (val, val, val);
                ////qDebug ()  << __PRETTY_FUNCTION__ << v;
                convImage->setPixel (ii, i0/50, v);//qRgb(val, val, val));
            }

            //qDebug () << __PRETTY_FUNCTION__ << ii << (double)stc2abs[ii];

        }
        if (i0==0)
        {
            radDataWidget * wStc2 = new radDataWidget();
            wStc2->setWindowTitle (tr("Stc2 after FFT"));
            QAbstractItemModel * radCModel = new QStandardItemModel (nd, 2, 0);// (nd2, na);
            radCModel->setHeaderData (0, Qt::Horizontal, QString("Real"), Qt::DisplayRole);
            radCModel->setHeaderData (1, Qt::Horizontal, QString("Image"), Qt::DisplayRole);
            radCModel->setHeaderData (2, Qt::Horizontal, QString("Module"), Qt::DisplayRole);
            for (int ii=0; ii<nd; ii++)
            {
                QModelIndex wIndex = radCModel->index (ii, 0);
                radCModel->setData (wIndex, (double)(stc2[2*ii]), Qt::DisplayRole);
                wIndex = radCModel->index (ii, 1);
                radCModel->setData (wIndex, (double)(stc2[2*ii+1]), Qt::DisplayRole);
//                wIndex = radCModel->index (ii, 2);
//                radCModel->setData (wIndex, (double)stc2abs[ii], Qt::DisplayRole);
            }
            wStc2->setModel (radCModel);
            QMdiSubWindow * subWStc2 = m_mdiArea->addSubWindow (wStc2);
            wStc2->show ();
            subWStc2->setAttribute (Qt::WA_DeleteOnClose);
        }
        if (fid6)
        {
            qDebug () << __PRETTY_FUNCTION__ << QString ("Write data");
            size_t h = fwrite (stc2, sizeof (double)/2, 2*nd, fid6);
            int ier = ferror (fid6);
            qDebug () << __PRETTY_FUNCTION__ << QString ("Data were written %1 bytes, error indicator =%2 ").arg (h).arg(ier);
            if (ier)
                qDebug () << __PRETTY_FUNCTION__ << tr ("Write error");
        }
        delete [] xfft;

        delete [] stc2abs;
        delete [] stc2;
    }
    delete [] vals;
    qDebug () << __PRETTY_FUNCTION__ << QString ("Data were read and processed");
开发者ID:YuriyRusinov,项目名称:radius,代码行数:67,代码来源:radmainwindow.cpp

示例13: qtractorTimeScaleItemDelegate

// Constructor.
qtractorTimeScaleForm::qtractorTimeScaleForm (
	QWidget *pParent, Qt::WindowFlags wflags )
	: QDialog(pParent, wflags)
{
	// Setup UI struct...
	m_ui.setupUi(this);

	// Window modality (let plugin/tool windows rave around).
	QDialog::setWindowModality(Qt::WindowModal);

	// Initialize locals.
	m_pTimeScale  = NULL;

	m_pTempoTap   = new QTime();
	m_iTempoTap   = 0;
	m_fTempoTap   = 0.0f;

	m_iDirtySetup = 0;
	m_iDirtyCount = 0;
	m_iDirtyTotal = 0;

	QHeaderView *pHeader = m_ui.TimeScaleListView->header();
	pHeader->setDefaultAlignment(Qt::AlignLeft);
#if QT_VERSION >= 0x050000
//	pHeader->setSectionResizeMode(QHeaderView::Custom);
	pHeader->setSectionResizeMode(QHeaderView::ResizeToContents);
	pHeader->setSectionsMovable(false);
#else
//	pHeader->setResizeMode(QHeaderView::Custom);
	pHeader->setResizeMode(QHeaderView::ResizeToContents);
	pHeader->setMovable(false);
#endif
	QAbstractItemModel *pHeaderModel = pHeader->model();
	pHeaderModel->setHeaderData(0, Qt::Horizontal,
		Qt::AlignCenter, Qt::TextAlignmentRole); // Bar
	pHeaderModel->setHeaderData(2, Qt::Horizontal,
		Qt::AlignCenter, Qt::TextAlignmentRole); // tempo

	m_ui.TimeScaleListView->setItemDelegate(
		new qtractorTimeScaleItemDelegate(m_ui.TimeScaleListView));
	m_ui.TimeScaleListView->setContextMenuPolicy(Qt::CustomContextMenu);

	// (Re)initial contents.
	// Default is main session time-scale of course...
	qtractorSession *pSession = qtractorSession::getInstance();
	if (pSession)
		setTimeScale(pSession->timeScale());

	// Try to restore normal window positioning.
	adjustSize();

	// UI signal/slot connections...
	QObject::connect(m_ui.TimeScaleListView,
		SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
		SLOT(selectItem()));
	QObject::connect(m_ui.TimeScaleListView,
		SIGNAL(customContextMenuRequested(const QPoint&)),
		SLOT(contextMenu(const QPoint&)));

	QObject::connect(m_ui.BarSpinBox,
		SIGNAL(valueChanged(int)),
		SLOT(barChanged(int)));
	QObject::connect(m_ui.TimeSpinBox,
		SIGNAL(valueChanged(unsigned long)),
		SLOT(timeChanged(unsigned long)));
	QObject::connect(m_ui.TimeSpinBox,
		SIGNAL(displayFormatChanged(int)),
		SLOT(refreshItems()));

	QObject::connect(m_ui.TempoSpinBox,
		SIGNAL(valueChanged(float, unsigned short, unsigned short)),
		SLOT(tempoChanged()));
	QObject::connect(m_ui.TempoSpinBox,
		SIGNAL(valueChanged(const QString&)),
		SLOT(tempoChanged()));
	QObject::connect(m_ui.TempoTapPushButton,
		SIGNAL(clicked()),
		SLOT(tempoTap()));
	QObject::connect(m_ui.TempoFactorPushButton,
		SIGNAL(clicked()),
		SLOT(tempoFactor()));

	QObject::connect(m_ui.MarkerTextLineEdit,
		SIGNAL(textChanged(const QString&)),
		SLOT(changed()));
	QObject::connect(m_ui.MarkerColorToolButton,
		SIGNAL(clicked()),
		SLOT(markerColor()));

	QObject::connect(m_ui.RefreshPushButton,
		SIGNAL(clicked()),
		SLOT(refresh()));
	QObject::connect(m_ui.AddPushButton,
		SIGNAL(clicked()),
		SLOT(addItem()));
	QObject::connect(m_ui.UpdatePushButton,
		SIGNAL(clicked()),
		SLOT(updateItem()));
	QObject::connect(m_ui.RemovePushButton,
//.........这里部分代码省略.........
开发者ID:davidpucheta,项目名称:qtractor,代码行数:101,代码来源:qtractorTimeScaleForm.cpp


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