Qt6 topics merged with General

Delay in executing widget program

  • HI All,

    I have a Main window with push buttons to open other windows, as shown below:

    Here both in Program window and Logs window , I have a back to main button which can take to the Main window.

    In the Logs window at present I'm having a real-time display of sensor.

    Everything seems fine if I start Logs from Main in the first time

    But, if I goto Programs -> back to Main -> Logs the Logs window is getting too much delayed.

    This is how I go back to Main from Program

    void stageProgram::on_pushButton_shoulderControl_clicked()
        this-> close();
        StageOneMain *newPatient = new StageOneMain(pLabel);
        newPatient-> show();

    Logs from Main

    void StageOneMain::on_pushButton_logs_clicked()
        window = new ShoulderControl(pLabel);
        window -> show();

    Anybody see some issue here?

  • @viniltc
    Do you have Qt::WA_DeleteOnClose on each of these classes? Else you're leaking a window every time.

  • Lifetime Qt Champion

    @viniltc Do you really need to close current window and create a new instance of the new one? You could simply call hide() instead of close() and next time if this window needs to be shown call show() again.
    Another solution would be to use one window with QStackedWidget and simply change the shown widget when one of the buttons is clicked.

  • @viniltc
    Apart from the leaks I mentioned in your existing code, either of @jsulm's suggestions are preferable to your approach.

  • @JonB @jsulm Thanks for your suggestions. How do I detect for any memory leaks?

  • Lifetime Qt Champion

    @viniltc said in Delay in executing widget program:

    How do I detect for any memory leaks?

    On Linux you can use Valgrind (QtCreator integrates it).

Log in to reply