Results 1 to 11 of 11

Thread: qt loading latency problem

  1. #1
    Join Date
    Mar 2011
    Posts
    23
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt loading latency problem

    I use Qt 4.8.5 on Linux in old hardware ( 800 Mhz processor, 256 MB memory). I created Qt gui project and added QLineEdit to gui. I only added this line
    Qt Code:
    1. ui->lineedit->setFocus();
    To copy to clipboard, switch view to plain text mode 
    to code. My problem is GUI frezes after I run program. If I type 'a' after I started program, 'a' was shown in lineedit after 3-4 seconds. Why it takes 3-4 seconds. How can I reduce it?

    video of latency

    sorry for my English
    Last edited by ahmetturan; 27th November 2013 at 10:27.

  2. The following user says thank you to ahmetturan for this useful post:


  3. #2
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: qt loading latency problem

    I'm afraid the problem is not relevant to setFocus() at all. State what the program does, paste your code in short if possible.

  4. The following user says thank you to saman_artorious for this useful post:


  5. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qt loading latency problem

    ui->lineedit->setFocus();
    Where did you add that line ?

  6. The following user says thank you to aamer4yu for this useful post:


  7. #4
    Join Date
    Mar 2011
    Posts
    23
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt loading latency problem

    @saman_artorious: program does nothing. I added nothing to code only ui->lineEdit->setFocus(); to mainwindow.cpp and QLineEdit to gui.

    @aamer4yu: I added source code. You can see ui->lineEdit->setFocus(); is after ui->setupUi(this);. Actually if I remove that line problem still happens.

    mainwindow.cpp
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9. ui->lineEdit->setFocus();
    10. }
    11.  
    12. MainWindow::~MainWindow()
    13. {
    14. delete ui;
    15. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. MainWindow w;
    8. w.show();
    9.  
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    mainwindow.h

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5.  
    6. namespace Ui {
    7. class MainWindow;
    8. }
    9.  
    10. class MainWindow : public QMainWindow
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. explicit MainWindow(QWidget *parent = 0);
    16. ~MainWindow();
    17.  
    18. private:
    19. Ui::MainWindow *ui;
    20. };
    21.  
    22. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

  8. The following user says thank you to ahmetturan for this useful post:


  9. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qt loading latency problem

    So the problem is not related to setFocus line..

    May be check the number of processes running on the target... the memory seems only 256 MB and may be the cause.

  10. The following user says thank you to aamer4yu for this useful post:


  11. #6
    Join Date
    Mar 2011
    Posts
    23
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt loading latency problem

    I wonder why flashing cursor on lineedit takes 3-4 secons. What is Qt doing in this time?

  12. The following user says thank you to ahmetturan for this useful post:


  13. #7
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt loading latency problem

    Only a guess: try to show the main window first and then pass focus to the lineEdit. When the window is created (by setupUi), it is hidden and cannot get focus. Subsequently, no part of the window can get focus. What will happen when you attempt to pass focus to a hidden window depends on the logic of Qt.

    If I have hit the target, you can reimplement showEvent() in the main window and pass the focus there.

  14. The following user says thank you to Radek for this useful post:


  15. #8
    Join Date
    Mar 2011
    Posts
    23
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt loading latency problem

    Actually problem is not setFocus(). Problem is why GUI freeze in first 3-4 seconds. What is Qt doing in this time? And what should I do reduce this?

  16. The following user says thank you to ahmetturan for this useful post:


  17. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qt loading latency problem

    Are you sure that your program is doing anything at that time?
    Maybe some other process is hogging resources

    Cheers,
    _

  18. The following user says thank you to anda_skoa for this useful post:


  19. #10
    Join Date
    Mar 2011
    Posts
    23
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt loading latency problem

    Quote Originally Posted by anda_skoa View Post
    Are you sure that your program is doing anything at that time?
    Yes I am sure. Because There is no code in project. Only there is one lineEdit in gui

    Quote Originally Posted by anda_skoa View Post
    Maybe some other process is hogging resources

    _
    There is no other running application in my os.

  20. #11
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qt loading latency problem

    A couple of ideas what you could investigate:

    - add a QTimer to your program and let it call a slot in regular intervals. in the slot do some log output, e.g.QTime::currentTime(). Check if this comes as expected or is paused or signifcantly delayed. This should give you a hint if the program itself is slow/blocked or something it interacts with

    - try a non-Qt program to rule out driver issues.

    Cheers,
    _

Similar Threads

  1. Replies: 1
    Last Post: 7th July 2013, 14:09
  2. Phonon - audio-output-problem and high latency
    By nearlyNERD in forum Qt Programming
    Replies: 3
    Last Post: 27th June 2012, 21:17
  3. DLL loading problem on Mac OSX
    By gib in forum Qt Programming
    Replies: 1
    Last Post: 16th September 2010, 07:24
  4. QTcpSocket - speed, latency, time
    By FatScouser in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2010, 12:25
  5. Reducing latency in mouse moves
    By PhilFM in forum Qt Programming
    Replies: 4
    Last Post: 6th September 2007, 09:38

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.