PDA

View Full Version : Obtaining list of running processes with Qt on a smartphone



zhengping
11th June 2010, 10:16
Hello,

I'm new to Qt programming, and am working on app development for the Symbian platform. My program needs to obtain the list of processes currently taking place within the mobile device, and add them to a listWidget. I'm currently working with the Nokia Qt SDK on Windows Vista.

The following is a Symbian S60 code snippet I got for doing so, but I need help adapting it for a Qt app on a smartphone. Any insight on procedure and libraries to include would be greatly appreciated; thanks in advance!



void CDriver_GuiAppView::GetProcessListL(void)

{
process = 1;
TFullName res;
TFullName temp;
TFindProcess find;

RDebug::Print(_L("\n \n List of processes running in the system:"));
CTextListBoxModel* model = iListBox->Model();
User::LeaveIfNull(model);

model->SetOwnershipType(ELbmOwnsItemArray);
CDesCArray* itemArray = static_cast<CDesCArray*>(model->ItemTextArray());

User::LeaveIfNull(itemArray);
itemArray->Reset();

while (find.Next(res) == KErrNone)
{
RProcess ph;
ph.Open(find);
RDebug::Print(_L("%S \n"),&res);
temp.Format(KListFormatString, KFolderIconSlot);
temp.Append(res);
itemArray->AppendL(temp);
iListBox->HandleItemAdditionL();
temp.Zero();

ph.Close();
}

iRoot = EFalse;
iListBox->SetCurrentItemIndex(0);
iListBox->DrawNow();
}

high_flyer
11th June 2010, 11:08
Your CDriver_GuiAppView will have to derive from a Qt class, probably a QDialog.
There you will have to put a QListWidget or QListView as a member.
Then in GetProcessListL() you can just fill the list widget something like:


void CDriver_GuiAppView::GetProcessListL(void)

{
//Get a string array of the processes, for example in to a QStringList.
QStringList lstProcesses = getProcessList(); //you have to implement that

for(int i=0; i< array.size(); i++){
m_proecesList->addItem(lstProcesses.at(i));
}
}

zhengping
14th June 2010, 03:27
Thanks for the advice; though I have another query regarding the function implementation in Qt. As my app must be in Qt and not Symbian C++, how can I use the APIs in Qt to write the getProcessList function?
I only started Qt programming itself a few weeks ago and am still going through the tutorials, so I'd be grateful for any assistance you and anyone in the community could provide.

(Sorry if I gave the impression I was combining code for Qt and Symbian. My mistake.)

high_flyer
14th June 2010, 08:49
As my app must be in Qt and not Symbian C++, how can I use the APIs in Qt to write the getProcessList function?
Qt and C++ are not exclusive, Qt is written with C++!
C++ is a language, Qt is a toolkit, a frame work.
Also, Qt offers you a cross platfom way of doing many things, and foremost GUI.
But low level stuff, you have to implement natively, and it sounds that what you need here will be native.


I only started Qt programming itself a few weeks ago...[snip]
Do you mean you just started programming in general or are you just new to Qt?
If its the former, I'd say such a task is a bit big on a beginner.

zhengping
14th June 2010, 13:27
Hello high_flyer, thanks for the help. Just to clarify: I mean I'm new to Qt. Been programming for a year for college, though only with low-level programs so far--what you'd see in an introductory text, up to structures, arrays and text file reading and writing. Right now I'm doing an internship that needs me to upgrade from there.

What Qt APIs will I need to get the processes for the QStringList? I'd appreciate any further help going forward... thanks again!

high_flyer
14th June 2010, 13:36
What Qt APIs will I need to get the processes for the QStringList?
Getting a string list will have to be done in native way, so I can't help you there.
Once you have a string list either in a vector or array, you can then add it to a QListWidget.

The code snippet you posted looks like its doing that.
It looks like TFullName might be string, so check out if it is (the documentation of the API you are using there), or what would be the way to convert it to str::string or c string, and from there you can build your QStringList which you then can add to a QListWidget.