user90879
29th March 2014, 16:16
I've made a winsock application that connects to a server. Upon connection it receives a bunch of packets I like to call "user ids". An example of one of these packets would be "C10x". The 'C' meaning someone has just connected. I also receive other information with this user id, such as their username. I store their user id and the corresponding username in a QHash, like this:
QHash<QString, QString> userInfo;
userInfo.insert(qUid, qUsername);
I then add these to my QTableWidget like this:
ui->tableWidget->insertRow(row);
QTableWidgetItem *item = new QTableWidgetItem(qUid);
QTableWidgetItem *item2 = new QTableWidgetItem(qUsername);
ui->tableWidget->setItem(row, 0,item);
ui->tableWidget->setItem(row, 1,item2);
row++;
When someone disconnects, I receive a packet that looks like this: "D10x", which means that the user 10x has disconnected. How can I search for "10x" in my QTableWidget and remove its respective row? Thanks in advance~
QHash<QString, QString> userInfo;
userInfo.insert(qUid, qUsername);
I then add these to my QTableWidget like this:
ui->tableWidget->insertRow(row);
QTableWidgetItem *item = new QTableWidgetItem(qUid);
QTableWidgetItem *item2 = new QTableWidgetItem(qUsername);
ui->tableWidget->setItem(row, 0,item);
ui->tableWidget->setItem(row, 1,item2);
row++;
When someone disconnects, I receive a packet that looks like this: "D10x", which means that the user 10x has disconnected. How can I search for "10x" in my QTableWidget and remove its respective row? Thanks in advance~