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:
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;
}
QList<QStandardItem *> MainWindow::prepareRow(uint32_t ID, const QString &first, const QString &second, const QString &third)
{
QList<QStandardItem *> rowItems;
QStandardItem *ptr = new QStandardItem(first);
rowItems << ptr;
ptr = new QStandardItem(second);
rowItems << ptr;
ptr = new QStandardItem(third);
rowItems << ptr;
QString tmp;
QTextStream uniquetmp(&tmp);
uniquetmp << ID;
ptr = new QStandardItem(tmp);
rowItems << ptr;
return rowItems;
}
To copy to clipboard, switch view to plain text mode
that's how I am placing ID in
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);
}
}
void MainWindow::alarm(uint32_t UniqueID, DateTimeType EventTime, QString Hosts, QString Name)
{
QString tmp;
QTextStream event_time(&tmp);
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());
QStandardItem *itemd1 = standardModel->invisibleRootItem();
itemd1->appendRow(preparedRow);
}
}
To copy to clipboard, switch view to plain text mode
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?
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
}
}
void MainWindow::Remove()
{
QItemSelectionModel *selected = ui.view->selectionModel();
QModelIndexList rowList = selected->selectedRows();
foreach(QModelIndex rowIndex, rowList) {
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
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks