Results 1 to 3 of 3

Thread: very slowly apps

  1. #1
    Join Date
    Oct 2007
    Location
    Poland
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Post very slowly apps

    I have problem with QProcess. My code:
    Qt Code:
    1. class Mencoder : public QObject
    2. {
    3. ...
    4. private:
    5. QProcess *proc;
    6. };
    7. ..
    8.  
    9. Mencoder::Mencoder( .../* some parameters */, QObject *parent ) : QObject( parent )
    10. {
    11. proc = new QProcess( this );
    12. connect( proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( update() ) );
    13. connect( proc, SIGNAL( finished(..) ), this, SLOT( on_finished(..) ) );
    14. ...
    15. proc->start( "mencoder", arg );
    16. }
    17.  
    18. void Mencoder::update()
    19. {
    20. ......
    21. emit newInfo( .... /*some new data for main apps*/ );
    22. }
    23.  
    24. void Mencoder::on_finished(..)
    25. {
    26. ..
    27. proc->close();
    28. deleteLater();
    29. }
    To copy to clipboard, switch view to plain text mode 

    Everything works, but i have problem with cpu usage. From system info i have this:
    %CPU COMMAND
    32 mencoder
    40 myApps
    23 xorg
    Wher's the problem?

  2. #2
    Join Date
    Jan 2008
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: very slowly apps

    i assume mencoder is outputting to fast or is updating a percentage or remaining time or something like that
    in this case i would delay emit newInfo(), so it would be emitted max every 50 msecs or something like that

    maybe it helps, just a thought

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: very slowly apps

    Qt Code:
    1. connect( proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( update() ) );
    To copy to clipboard, switch view to plain text mode 
    You are updating the display every time there is something to read from the process. That's not a very good thing to do, regardless of what you do within update (especially that your paintEvent() is probably not very well designed).

    I never had problems with mencoder and cpu usage of the frontend.

Similar Threads

  1. How to ship Qt apps?
    By Morea in forum Installation and Deployment
    Replies: 2
    Last Post: 22nd June 2008, 13:22
  2. run QT Apps on PALM or Handy
    By raphaelf in forum Newbie
    Replies: 5
    Last Post: 5th September 2007, 12:27
  3. signals and slots between 2 Apps?
    By nupul in forum Qt Programming
    Replies: 9
    Last Post: 12th April 2006, 12:38
  4. Console apps in Kde Qt
    By peedarp in forum Qt Programming
    Replies: 5
    Last Post: 1st February 2006, 11:43
  5. QT4 console apps
    By ucntcme in forum Newbie
    Replies: 5
    Last Post: 24th January 2006, 11:18

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.