QTableWidget process list
-
Hi, I'm making a dialog with a QTableWidget and I want to fill it with processes that a user can select from
here's the code i've got so far
@attach::attach(QWidget *parent) :
QDialog(parent),
ui(new Ui::attach)
{
Qt::WindowFlags flags = windowFlags() ;
flags |= Qt::CustomizeWindowHint ;
flags &= ~Qt::WindowCloseButtonHint ;
setWindowFlags( flags ) ;
ui->setupUi(this);QStandardItemModel *pListModel = new QStandardItemModel(0,1,this); pListModel->setHorizontalHeaderItem(0, new QStandardItem(QString("Process"))); HANDLE sShot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); PROCESSENTRY32* processInfo=new PROCESSENTRY32; processInfo->dwSize=sizeof(PROCESSENTRY32); int index=0; while(Process32Next(sShot,processInfo)!=FALSE) { QString lul; lul.fromWCharArray(processInfo->szExeFile); pListModel->setItem(index, new QStandardItem(lul)); index = index + 1; } CloseHandle(sShot); ui->processTableView->setModel(pListModel);
}@
The QTableWidget has one column named processes. I would like all the rows in this column to be filled with process names. This code makes the amount of rows equal to the amount of currently running processes, however the rows contain no text?
-
I fixed it myself. Very simple solution because I am a moron.
I changed this:
@lul.fromWCharArray(processInfo->szExeFile);@to this to get it working
@lul = lul.fromWCharArray(processInfo->szExeFile);@