It's bit of a mess because I have a pair of vector arrays one for labels on the table another for pointers to endpoints.
You will need to substitute something for TestEndpoint.
std::vector<QLabel*> m_endpoint_labels;
std::vector<TestEndpoint*> m_testendpoint_items;
//QTableWidget *endpoint_table;
void Add_Data(string serial_num, TestEndpoint*e)
{
endpoint_table->setRowCount(endpoint_table->rowCount() + 1);
endpoint_table->setCellWidget(endpoint_table->rowCount() - 1, 0, lbl);
m_endpoint_labels.push_back(lbl);
m_testendpoint_items.push_back(e->getEndpoint());
}
void MyQtApp::onRemoveFailedButton()
{
unsigned int count = 0;
// Look through all endpoints...
while(count < m_testendpoint_items.size()) {
// Is the endpoint offline?
if(!m_testendpoint_items[count]->getEndpoint().isOnline()) {
delete m_endpoint_labels[count];
m_testendpoint_items.erase(m_testendpoint_items.begin() + count);
m_endpoint_labels.erase(m_endpoint_labels.begin() + count);
endpoint_table->removeRow(count);
} else count ++;
}
}
std::vector<QLabel*> m_endpoint_labels;
std::vector<TestEndpoint*> m_testendpoint_items;
//QTableWidget *endpoint_table;
void Add_Data(string serial_num, TestEndpoint*e)
{
endpoint_table->setRowCount(endpoint_table->rowCount() + 1);
QLabel *lbl = new QLabel(serial_num.c_str());
endpoint_table->setCellWidget(endpoint_table->rowCount() - 1, 0, lbl);
m_endpoint_labels.push_back(lbl);
m_testendpoint_items.push_back(e->getEndpoint());
}
void MyQtApp::onRemoveFailedButton()
{
unsigned int count = 0;
// Look through all endpoints...
while(count < m_testendpoint_items.size()) {
// Is the endpoint offline?
if(!m_testendpoint_items[count]->getEndpoint().isOnline()) {
delete m_endpoint_labels[count];
m_testendpoint_items.erase(m_testendpoint_items.begin() + count);
m_endpoint_labels.erase(m_endpoint_labels.begin() + count);
endpoint_table->removeRow(count);
} else count ++;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks