Results 1 to 6 of 6

Thread: Obtaining list of running processes with Qt on a smartphone

  1. #1
    Join Date
    Jun 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Obtaining list of running processes with Qt on a smartphone

    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!

    Qt Code:
    1. void CDriver_GuiAppView::GetProcessListL(void)
    2.  
    3. {
    4. process = 1;
    5. TFullName res;
    6. TFullName temp;
    7. TFindProcess find;
    8.  
    9. RDebug::Print(_L("\n \n List of processes running in the system:"));
    10. CTextListBoxModel* model = iListBox->Model();
    11. User::LeaveIfNull(model);
    12.  
    13. model->SetOwnershipType(ELbmOwnsItemArray);
    14. CDesCArray* itemArray = static_cast<CDesCArray*>(model->ItemTextArray());
    15.  
    16. User::LeaveIfNull(itemArray);
    17. itemArray->Reset();
    18.  
    19. while (find.Next(res) == KErrNone)
    20. {
    21. RProcess ph;
    22. ph.Open(find);
    23. RDebug::Print(_L("%S \n"),&res);
    24. temp.Format(KListFormatString, KFolderIconSlot);
    25. temp.Append(res);
    26. itemArray->AppendL(temp);
    27. iListBox->HandleItemAdditionL();
    28. temp.Zero();
    29.  
    30. ph.Close();
    31. }
    32.  
    33. iRoot = EFalse;
    34. iListBox->SetCurrentItemIndex(0);
    35. iListBox->DrawNow();
    36. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Obtaining list of running processes with Qt on a smartphone

    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:
    Qt Code:
    1. void CDriver_GuiAppView::GetProcessListL(void)
    2.  
    3. {
    4. //Get a string array of the processes, for example in to a QStringList.
    5. QStringList lstProcesses = getProcessList(); //you have to implement that
    6.  
    7. for(int i=0; i< array.size(); i++){
    8. m_proecesList->addItem(lstProcesses.at(i));
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jun 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: Obtaining list of running processes with Qt on a smartphone

    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.)
    Last edited by zhengping; 14th June 2010 at 04:46.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Obtaining list of running processes with Qt on a smartphone

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jun 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: Obtaining list of running processes with Qt on a smartphone

    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!

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Obtaining list of running processes with Qt on a smartphone

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. The following user says thank you to high_flyer for this useful post:

    zhengping (15th June 2010)

Similar Threads

  1. QWidgets and processes
    By mihaiadrian in forum Qt Programming
    Replies: 3
    Last Post: 19th May 2010, 17:38
  2. Replies: 2
    Last Post: 12th January 2010, 01:13
  3. Display from multiple processes in one GUI
    By abernat in forum Qt Programming
    Replies: 3
    Last Post: 17th September 2009, 21:08
  4. QSharedMemory in processes from different accounts
    By Ursa in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2009, 10:50
  5. Enumerate processes using Qt
    By Ben.Hines in forum Qt Programming
    Replies: 5
    Last Post: 14th February 2006, 16:45

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.