Results 1 to 11 of 11

Thread: The program start slowly with repaint problem

  1. #1
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Question The program start slowly with repaint problem

    In attach you may view empty window when programm starting, after few second his redraw normal.

    I fix this by add this in constructor and remove show() from main.cpp:

    Qt Code:
    1. QMetaObject::invokeMethod(this, "show", Qt::QueuedConnection);
    To copy to clipboard, switch view to plain text mode 

    In mainwindow consturctor i create 2 instances QHttp my be in this problem?
    Attached Images Attached Images

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: The program start slowly with repaint problem

    Please rephrase that, give us more details and perhaps some code.
    (Sorry, but I fail to understand what your problem is, I don't know what you are trying to do or where QHttp comes into play.)

  3. #3
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: The program start slowly with repaint problem

    I try say, what i don't want see empty window while program running. Inside constructor i create 2 instances QHttp.

  4. #4
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: The program start slowly with repaint problem

    can you show us you constructors code?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. #5
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: The program start slowly with repaint problem

    Qt Code:
    1. SpoList::SpoList(QWidget *parent)
    2. : QMainWindow(parent), twCountries(0), progressDialog(this)
    3. {
    4. //QErrorMessage::qtHandler();
    5. setupUi(this);
    6. readSettings();
    7. QDateEdit *dateEdit = new QDateEdit(this);
    8. QDate earlerDate = QDate::currentDate();
    9. earlerDate = earlerDate.addDays(-10);
    10. dateEdit->setDate(earlerDate);
    11. dateEdit->setCalendarPopup(true);
    12. toolBar->addWidget(dateEdit);
    13.  
    14. http = new QHttp(this);
    15.  
    16. connect(http, SIGNAL(requestFinished(int, bool)),
    17. this, SLOT(httpRequestFinished(int, bool)));
    18. connect(http, SIGNAL(requestStarted(int)), this, SLOT(httpRequestStarted(int)));
    19. connect(http, SIGNAL(dataReadProgress(int, int)),
    20. this, SLOT(updateDataReadProgress(int, int)));
    21. connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
    22. this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
    23. connect(http, SIGNAL(authenticationRequired(const QString &, quint16, QAuthenticator *)),
    24. this, SLOT(slotAuthenticationRequired(const QString &, quint16, QAuthenticator *)));
    25.  
    26. connect(&progressDialog, SIGNAL(canceled()), http, SLOT(abort()));
    27. http->setHost(host);
    28.  
    29. spohttp = new QHttp(this);
    30. connect(spohttp, SIGNAL(requestFinished(int, bool)),
    31. this, SLOT(httpSpoRequestFinished(int, bool)));
    32. connect(spohttp, SIGNAL(requestStarted(int)), this, SLOT(httpSpoRequestStarted(int)));
    33. connect(spohttp, SIGNAL(dataReadProgress(int, int)),
    34. this, SLOT(updateSpoDataReadProgress(int, int)));
    35. connect(spohttp, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
    36. this, SLOT(readSpoResponseHeader(const QHttpResponseHeader &)));
    37. connect(spohttp, SIGNAL(authenticationRequired(const QString &, quint16, QAuthenticator *)),
    38. this, SLOT(slotSpoAuthenticationRequired(const QString &, quint16, QAuthenticator *)));
    39. spohttp->setHost(host);
    40. screenCenter();
    41. QMetaObject::invokeMethod(this, "show", Qt::QueuedConnection);
    42. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: The program start slowly with repaint problem

    What would be more interesting is what you do want to see, not what you don't.

    You have two choices:
    * make the window not appear at all til some condition is met (e.g. your QHttp instances have connected, finished or whatever)
    * make the window appear with content right away (call the necessary stuff like show, screenCenter etc before creating the QHttp stuff?)

    HTH

  7. #7
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: The program start slowly with repaint problem

    This not help. Only invokeMethod helps.

    Qt Code:
    1. SpoList::SpoList(QWidget *parent)
    2. : QMainWindow(parent), twCountries(0), progressDialog(this)
    3. {
    4. http = new QHttp(this);
    5.  
    6. connect(http, SIGNAL(requestFinished(int, bool)),
    7. this, SLOT(httpRequestFinished(int, bool)));
    8. connect(http, SIGNAL(requestStarted(int)), this, SLOT(httpRequestStarted(int)));
    9. connect(http, SIGNAL(dataReadProgress(int, int)),
    10. this, SLOT(updateDataReadProgress(int, int)));
    11. connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
    12. this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
    13. connect(http, SIGNAL(authenticationRequired(const QString &, quint16, QAuthenticator *)),
    14. this, SLOT(slotAuthenticationRequired(const QString &, quint16, QAuthenticator *)));
    15.  
    16. connect(&progressDialog, SIGNAL(canceled()), http, SLOT(abort()));
    17.  
    18. http->setHost(host);
    19.  
    20. spohttp = new QHttp(this);
    21. connect(spohttp, SIGNAL(requestFinished(int, bool)),
    22. this, SLOT(httpSpoRequestFinished(int, bool)));
    23. connect(spohttp, SIGNAL(requestStarted(int)), this, SLOT(httpSpoRequestStarted(int)));
    24. connect(spohttp, SIGNAL(dataReadProgress(int, int)),
    25. this, SLOT(updateSpoDataReadProgress(int, int)));
    26. connect(spohttp, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
    27. this, SLOT(readSpoResponseHeader(const QHttpResponseHeader &)));
    28. connect(spohttp, SIGNAL(authenticationRequired(const QString &, quint16, QAuthenticator *)),
    29. this, SLOT(slotSpoAuthenticationRequired(const QString &, quint16, QAuthenticator *)));
    30. spohttp->setHost(host);
    31. setupUi(this);
    32. readSettings();
    33. QDateEdit *dateEdit = new QDateEdit(this);
    34. QDate earlerDate = QDate::currentDate();
    35. earlerDate = earlerDate.addDays(-10);
    36. dateEdit->setDate(earlerDate);
    37. dateEdit->setCalendarPopup(true);
    38. toolBar->addWidget(dateEdit);
    39. screenCenter();
    40. show();
    41. }
    To copy to clipboard, switch view to plain text mode 

    I comment all and leave only setupUi() problem not gone, something wrong inside core. May be plugins.
    Last edited by SABROG; 21st May 2009 at 12:34.

  8. #8
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: The program start slowly with repaint problem

    My advice would be to remove the QHttp initilization, connections etc from MainWindow constructor, and put it in some other method, lets say init(). Then make the init() method as a slot and connect to some button or timer or whatever, show the window (in main() not in constructor), then push the button conected to init(). It will make you sure that window is painted and everything is ok, so you can then run the QHttp stuff.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  9. #9
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: The program start slowly with repaint problem

    I post early what i remove all from constructor and problem not gone.

    Profiler say what cpu eat this method:
    ZN14QWaitCondition4waitEP6QMutexm 97,64 3 8451235,51

    I don't use QWaitCondition and QMutex inside program. With other programs i don't have this problem.

    May be network get this effect. This code from qeventdispatcher_win.cpp
    Qt Code:
    1. void SocketAsyncHandler::run()
    2. {
    3. do {
    4. mutex.lock();
    5.  
    6. while (!supposedToDie && sockets.isEmpty()) {
    7. cond.wait(&mutex);
    8. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by SABROG; 21st May 2009 at 14:17.

  10. #10
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: The program start slowly with repaint problem

    So I think that you can also check the callers of those methods and than investigate what causes this slow down.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  11. #11
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: The program start slowly with repaint problem

    Callers? QApplication.exec()

Similar Threads

  1. QProcess Problem: Program doesnt start
    By musaulker in forum Newbie
    Replies: 5
    Last Post: 30th April 2020, 23:07
  2. QProcess problem (Main program hangs)
    By sincnarf in forum Qt Programming
    Replies: 5
    Last Post: 11th October 2007, 09:26
  3. problem in doing database program
    By wei243 in forum Qt Programming
    Replies: 0
    Last Post: 4th April 2007, 12:01
  4. repaint problem in QTextEdit
    By kennyxing in forum Qt Programming
    Replies: 2
    Last Post: 10th November 2006, 08:49
  5. Console Program Problem
    By ball in forum Qt Programming
    Replies: 9
    Last Post: 28th May 2006, 09:05

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.