本文整理汇总了C++中QTableWidgetItem::data方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableWidgetItem::data方法的具体用法?C++ QTableWidgetItem::data怎么用?C++ QTableWidgetItem::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableWidgetItem
的用法示例。
在下文中一共展示了QTableWidgetItem::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
int TableWidgetItem::data ( lua_State * L )// ( int role ) virtual QVariant const
{
QTableWidgetItem* lhs = ValueInstaller2<QTableWidgetItem>::check( L, 1 );
int role = Util::toInt( L, 2 );
QVariant* res = ValueInstaller2<QVariant>::create( L );
*res = lhs->data( role );
return 1;
}
示例2: retranslateUi
/** Retranslate header columns. */
void Playlist::retranslateUi()
{
for (int i=0; i < columnCount(); i++) {
QTableWidgetItem *headerItem = horizontalHeaderItem(i);
const QString text = tr(headerItem->data(Qt::UserRole+1).toString().toStdString().data());
headerItem->setText(text);
columns->actions().at(i)->setText(text);
}
}
示例3: color
QColor KColorCells::color(int index) const
{
QTableWidgetItem * tmpItem = item(index / columnCount(), index % columnCount());
if (tmpItem != 0)
return tmpItem->data(Qt::BackgroundRole).value<QColor>();
return QColor();
}
示例4: cellClicked
void IndexDialog::cellClicked(int row,int column){
if(column == 0){
if(create_flag){
QTableWidgetItem *item = tbColumnList->item(row,column);
bool checked = item->data(Qt::EditRole).toBool();
item->setData(Qt::EditRole,!checked);
}
}
}
示例5: UpdateStatsView
void ClientMain::UpdateStatsView()
{
ui.lblGameCyclesData->setText(tr("%1").arg(m_pIStrategizer->GameModel()->Clock().ElapsedGameCycles()));
map<ObjectStateType, set<TID>> workersState;
auto workerType = m_pIStrategizer->GameModel()->Self()->Race()->GetWorkerType();
int workerCount = 0;
for (auto& entityR : m_pIStrategizer->GameModel()->Self()->Entities())
{
if (entityR.second->TypeId() == workerType)
{
workersState[(ObjectStateType)entityR.second->P(OP_State)].insert(entityR.first);
++workerCount;
}
}
ui.lblWorkersCountData->setText(QString("%1").arg(workerCount));
QTableWidgetItem* cell = NULL;
for(int row = 0; row < ui.tblWorkerState->rowCount(); ++row)
{
cell = ui.tblWorkerState->item(row, 1);
ObjectStateType state = (ObjectStateType)cell->data(Qt::UserRole).toInt();
QString txt =QString("[%1]{").arg(workersState[state].size());
for (auto workerId : workersState[state])
{
auto pEntity = m_pIStrategizer->GameModel()->Self()->GetEntity(workerId);
if (pEntity != nullptr)
{
bool isLocked = pEntity->IsLocked();
txt += QString("%1").arg(workerId);
txt += QString("[%2],").arg(isLocked ? "L" : "F");
}
}
txt += "}";
cell->setText(txt);
}
ui.tblWorkerState->resizeColumnsToContents();
ui.lblFPSData->setText(tr("%1").arg("-"));
int currMemoryUsage = (int)GetProcessUsedMemoryKB();
ui.lblCurrUsedMemoryData->setText(QString("%1").arg(currMemoryUsage));
int deltaMemoryUsage = abs((int)currMemoryUsage - (int)m_startMemoryUsage);
ui.lblDeltaMemoryData->setText(QString("%1").arg(deltaMemoryUsage));
ui.lblObjectsMemoryData->setText(QString("%1").arg(EngineObject::AliveObjectsMemoryUsage() / 1024));
ui.lblObjectsCountData->setText(QString("%1").arg(EngineObject::AliveObjectsCount()));
}
示例6: slotAccept
void ShortcutsImpl::slotAccept()
{
for(int row=0; row<table->rowCount(); row++ )
{
QTableWidgetItem *item = table->item(row, 0);
QAction *action = (QAction *)variantToAction( item->data(Qt::UserRole) );
QString shortcut = table->item(row, 1)->text();
action->setShortcut( shortcut );
}
}
示例7: SlotStartScript
void QTServer::SlotStartScript(const int &nRow) {
QTableWidgetItem* pItemAcc = ui.tableWidget->item(nRow, 0);
QTcpSocket* pTcpSocket = (QTcpSocket*)(pItemAcc->data(Qt::UserRole + 0x200)).toInt();
if (pTcpSocket) {
SOCKET_INFO socket_info;
RtlZeroMemory(&socket_info, sizeof(SOCKET_INFO));
socket_info.message = SOCKET_MESSAGE::StartScript;
QTableWidgetItem* pItemScript = ui.tableWidget->item(nRow, 3);
QString qstrScript = pItemScript->data(Qt::DisplayRole).toString(); // 脚本
std::string strScript = std::string((const char*)qstrScript.toLocal8Bit());
strcpy_s(socket_info.szAccOrScript, strScript.c_str());
QByteArray datasend;
datasend.append((const char*)&socket_info);
pTcpSocket->write((const char*)&socket_info, sizeof(SOCKET_INFO));
pTcpSocket->flush();
QTableWidgetItem* pItemStatus = ui.tableWidget->item(nRow, 7);
pItemStatus->setData(Qt::DisplayRole, QStringLiteral("挂机中"));
}
}
示例8: converterDeleteNote
void UAreaResultsTable::converterDeleteNote(int row)
{
QTableWidgetItem *item = tableRecycleBin->item(row, indexMainColumn);
if(item)
{
QString nameFile = item->data(pointerOnDataItemNote).value<QString>();
emit deleteNote(nameFile);
emit refreshTables();
}
}
示例9: openDeleteAutoProfileConfirmDialog
void MainSettingsDialog::openDeleteAutoProfileConfirmDialog()
{
QMessageBox msgBox;
msgBox.setText(tr("Are you sure you want to delete the profile?"));
msgBox.setStandardButtons(QMessageBox::Discard | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
int ret = msgBox.exec();
if (ret == QMessageBox::Discard)
{
int selectedRow = ui->autoProfileTableWidget->currentRow();
if (selectedRow >= 0)
{
QTableWidgetItem *item = ui->autoProfileTableWidget->item(selectedRow, 5);
//QTableWidgetItem *itemDefault = ui->autoProfileTableWidget->item(selectedRow, 4);
AutoProfileInfo *info = item->data(Qt::UserRole).value<AutoProfileInfo*>();
if (info->isCurrentDefault())
{
if (info->getGUID() == "all")
{
delete allDefaultProfile;
allDefaultProfile = 0;
}
else if (defaultAutoProfiles.contains(info->getGUID()))
{
defaultAutoProfiles.remove(info->getGUID());
defaultList.removeAll(info);
delete info;
info = 0;
}
}
else
{
if (deviceAutoProfiles.contains(info->getGUID()))
{
QList<AutoProfileInfo*> temp = deviceAutoProfiles.value(info->getGUID());
temp.removeAll(info);
deviceAutoProfiles.insert(info->getGUID(), temp);
}
if (exeAutoProfiles.contains(info->getExe()))
{
QList<AutoProfileInfo*> temp = exeAutoProfiles.value(info->getExe());
temp.removeAll(info);
exeAutoProfiles.insert(info->getExe(), temp);
}
profileList.removeAll(info);
delete info;
info = 0;
}
}
ui->autoProfileTableWidget->removeRow(selectedRow);
}
}
示例10: SlotMessageRead
void QTServer::SlotMessageRead() {
for (int i = 0; i < m_tcpSocketList.length(); i++) {
if (m_tcpSocketList[i]->bytesAvailable() > 0) {
QByteArray qba = m_tcpSocketList[i]->readAll(); // 收取m_tcpSocket中的所有数据
PSOCKET_INFO data = (PSOCKET_INFO)qba.data();
int nCount = ui.tableWidget->rowCount();
if (nCount) {
for (int nCurrentRow = 0; nCurrentRow < nCount; nCurrentRow++) {
QTableWidgetItem* pItemAcc = ui.tableWidget->item(nCurrentRow, 0);
QString qstrAcc = pItemAcc->data(Qt::DisplayRole).toString(); //账号
std::string strAcc = std::string((const char*)qstrAcc.toLocal8Bit());
if (strAcc == std::string(data->szAccOrScript)) {
pItemAcc->setData(Qt::UserRole + 0x200, (int)m_tcpSocketList[i]);
switch (data->message) {
case SOCKET_MESSAGE::GetScript:
SOCKET_INFO socket_info;
RtlZeroMemory(&socket_info, sizeof(SOCKET_INFO));
socket_info.message = SOCKET_MESSAGE::GetScript;
QTableWidgetItem* pItemScript = ui.tableWidget->item(nCurrentRow, 3);
QString qstrScript = pItemScript->data(Qt::DisplayRole).toString(); // 脚本
std::string strScript = std::string((const char*)qstrScript.toLocal8Bit());
strcpy_s(socket_info.szAccOrScript, strScript.c_str());
QByteArray datasend;
datasend.append((const char*)&socket_info);
m_tcpSocketList[i]->write((const char*)&socket_info, sizeof(SOCKET_INFO));
//m_tcpSocketList[i]->waitForBytesWritten();
//martin->Debug("State:%d ", m_tcpSocketList[i]->state());
m_tcpSocketList[i]->flush();
QTableWidgetItem* pItemStatus = ui.tableWidget->item(nCurrentRow, 7);
pItemStatus->setData(Qt::DisplayRole, QStringLiteral("挂机中")); // 脚本
break;
}
break;
}
}
}
}
}
}
示例11: converterHideNote
void UAreaResultsTable::converterHideNote()
{
QTableWidgetItem *currentItem = tableNotes->item(tableNotes->currentRow(),
indexMainColumn);
if(currentItem)
{
Note *note = currentItem->data(pointerOnDataItemNote).value<Note*>();
emit hideNote(note);
emit refreshTables();
}
}
示例12: updateCallTimers
void MainWindow::updateCallTimers()
{
for(int row=0; row<ui->tableCalls->rowCount(); row++)
{
QTableWidgetItem* item = ui->tableCalls->item(row, 2);
QSharedPointer<Call> call = g_FSHost->getCallByUUID(item->data(Qt::UserRole).toString());
QTime time = call.data()->getCurrentStateTime();
item->setText(time.toString("hh:mm:ss"));
item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
}
}
示例13: showSegmentParameters
void ViennaMiniForm::showSegmentParameters(int row, int, int, int) // the second parameter 'column' is obsolete atm
{
if(row < 0) return;
QTableWidgetItem* widgetItem = ui->tableWidget->item(row, 0);
int segment_id = widgetItem->data(Qt::UserRole).toInt();
// deactivating autoexclusive enabls to unselect all radio buttons
ui->radioButtonContactSingle->setAutoExclusive(false);
ui->radioButtonContactRange->setAutoExclusive(false);
ui->lineEditSegmentName->setText(device_parameters[segment_id].name);
ui->checkBoxContact->setChecked(device_parameters[segment_id].isContact);
ui->radioButtonContactSingle->setChecked(device_parameters[segment_id].isContactSingle);
ui->lineEditContactSingle->setText(QString::number(device_parameters[segment_id].contact));
ui->radioButtonContactRange->setChecked(device_parameters[segment_id].isContactRange);
ui->lineEditContactRangeFrom->setText(QString::number(device_parameters[segment_id].contactFrom));
ui->lineEditContactRangeTo->setText(QString::number(device_parameters[segment_id].contactTo));
ui->lineEditWorkfunction->setText(QString::number(device_parameters[segment_id].workfunction));
ui->checkBoxOxide->setChecked(device_parameters[segment_id].isOxide);
ui->checkBoxSemiconductor->setChecked(device_parameters[segment_id].isSemiconductor);
ui->lineEditSemiconductorDonors->setText(QString::number(device_parameters[segment_id].donors));
ui->lineEditSemiconductorAcceptors->setText(QString::number(device_parameters[segment_id].acceptors));
// make sure that only one of the available radios can be selected
ui->radioButtonContactSingle->setAutoExclusive(true);
ui->radioButtonContactRange->setAutoExclusive(true);
// based on is{contact,oxide,semiconductor} deactivate/activate the corresponding parameter ui elements
if(device_parameters[segment_id].isContact)
{
this->toggleSegmentContact(true);
ui->comboBoxContactMaterial->setCurrentIndex(ui->comboBoxContactMaterial->findText(device_parameters[segment_id].material));
}
else
this->toggleSegmentContact(false);
if(device_parameters[segment_id].isOxide)
{
this->toggleSegmentOxide(true);
ui->comboBoxOxideMaterial->setCurrentIndex(ui->comboBoxOxideMaterial->findText(device_parameters[segment_id].material));
}
else
this->toggleSegmentOxide(false);
if(device_parameters[segment_id].isSemiconductor)
{
this->toggleSegmentSemiconductor(true);
ui->comboBoxSemiconductorMaterial->setCurrentIndex(ui->comboBoxSemiconductorMaterial->findText(device_parameters[segment_id].material));
}
else
this->toggleSegmentSemiconductor(false);
}
示例14:
QPair<QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int> > QgsDatumTransformDialog::selectedDatumTransforms()
{
int row = mDatumTransformTableWidget->currentRow();
QPair< QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int > > sdt;
sdt.first.first = mSourceCrs;
sdt.second.first = mDestinationCrs;
if ( row >= 0 )
{
QTableWidgetItem *srcItem = mDatumTransformTableWidget->item( row, 0 );
sdt.first.second = srcItem ? srcItem->data( Qt::UserRole ).toInt() : -1;
QTableWidgetItem *destItem = mDatumTransformTableWidget->item( row, 1 );
sdt.second.second = destItem ? destItem->data( Qt::UserRole ).toInt() : -1;
}
else
{
sdt.first.second = -1;
sdt.second.second = -1;
}
return sdt;
}
示例15: ShowPoint
/**
* @brief ShowPoint show selected point
*/
void DialogHistory::ShowPoint()
{
QVector<VToolRecord> *history = doc->getHistory();
if (history->size()>0)
{
QTableWidgetItem *item = ui->tableWidget->item(0, 1);
item->setSelected(true);
cursorToolRecordRow = 0;
item = ui->tableWidget->item(0, 0);
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
emit ShowHistoryTool(id, Qt::green, true);
}
}