Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTableWidget process list
Forum Updated to NodeBB v4.3 + New Features

QTableWidget process list

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qtTwist
    wrote on 23 Jun 2012, 05:15 last edited by
    #1

    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?

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qtTwist
      wrote on 24 Jun 2012, 03:31 last edited by
      #2

      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);@

      1 Reply Last reply
      0

      1/2

      23 Jun 2012, 05:15

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved