Extracting data from appended row
I am trying to grab a specific part of a row upon selection and send the data as the original data type it was (uint32_t). Here are the pieces of code relevant:
Code:
QList<QStandardItem
*> MainWindow
::prepareRow(uint32_t ID,
const QString &first,
const QString &second,
const QString &third
){
QList<QStandardItem *> rowItems;
rowItems << ptr;
rowItems << ptr;
rowItems << ptr;
uniquetmp << ID;
rowItems << ptr;
return rowItems;
}
that's how I am placing ID in
Code:
void MainWindow
::alarm(uint32_t UniqueID, DateTimeType EventTime,
QString Hosts,
QString Name
) {
event_time.setFieldWidth(1);
event_time << EvenTime.
Hour <<
QString(":") << EventTime.
Min <<
QString(":") << EventTime.
Sec;
bool found= false;
std::vector<iterator it = Alarms.begin();
while (it != Alarms.end())
{
std::string temp1 = Name.toLatin1();
std::string temp2 = it->name;
if (Name.compare(it->name.c_str()) == 0)
{
found = true;
break;
}
}
if (found)
{
QList<QStandardItem *> preparedRow = prepareRow(ID, tmp, HostName, it->brief.c_str());
itemd1->appendRow(preparedRow);
}
}
Now I'm trying to remove a specific row with the following function. Upon removing it, I want to get ID back and into type uint32_t. Any suggestions?
Code:
void MainWindow::Remove()
{
QModelIndexList rowList = selected->selectedRows();
standardModel->removeRow(rowIndex.row(), rowIndex.parent());
//I'm guessing i want to grab it here? Don't know how to specify that I only want ID and want to convert to uint32_t
}
}
Re: Extracting data from appended row
QVariant::toUInt() seems a likely candidate if you use data() to get the value, or QString::toUint()/toULong() if you use text().
Re: Extracting data from appended row
Thanks I will try that out and let you know!