Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How To "Loading"......
Forum Updated to NodeBB v4.3 + New Features

How To "Loading"......

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 772 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qazaq408
    wrote on 18 Oct 2018, 06:05 last edited by
    #1

    The programme need popu a dialog when user click a button,but the dialog need to do some work that maybe need to cost 3-5 sec when it launch....
    As you know,it's a bad idea that the user must cost 3-5 sec to wait the dialog's show.I find a pix.gif to cover that the dialog need to cost 3-5 sec to launch...
    0_1539841800926_load.gif

    This is the Load.gif....

    And the code looks like this

    void APT::allowRecoderMsg()  //the slot connect the single of QPushButton's 
    {
        load_Movie->setFileName(tr(":/source/pix/Load.gif"));
        load_Label->setMovie(load_Movie);
    
        load_Move->start();
        load_Label->show();
       
        if(recorde_Dialog != null)
            recorde_Dialog = new RecordeDialog(this);  //thie line will cost 3-5 sec
    
        load_Label->hide();
        recorde_Dialog->exec();
    }
    

    On my plan,I play a gif(on the QLabel) first, and executive the constructor of the class RecordeDialog(it will cost 3-5 sec),when the constructor of class RecordeDialog had executived,I hide the gif(label->hide()) and show the dialog(dialog->exec());
    But in fact ,when i executive the construct of class RecordeDialog,the gif will be stop..How to keep the GIF on running when dialog is executiving?

    R 1 Reply Last reply 18 Oct 2018, 07:08
    0
    • Q qazaq408
      18 Oct 2018, 06:05

      The programme need popu a dialog when user click a button,but the dialog need to do some work that maybe need to cost 3-5 sec when it launch....
      As you know,it's a bad idea that the user must cost 3-5 sec to wait the dialog's show.I find a pix.gif to cover that the dialog need to cost 3-5 sec to launch...
      0_1539841800926_load.gif

      This is the Load.gif....

      And the code looks like this

      void APT::allowRecoderMsg()  //the slot connect the single of QPushButton's 
      {
          load_Movie->setFileName(tr(":/source/pix/Load.gif"));
          load_Label->setMovie(load_Movie);
      
          load_Move->start();
          load_Label->show();
         
          if(recorde_Dialog != null)
              recorde_Dialog = new RecordeDialog(this);  //thie line will cost 3-5 sec
      
          load_Label->hide();
          recorde_Dialog->exec();
      }
      

      On my plan,I play a gif(on the QLabel) first, and executive the constructor of the class RecordeDialog(it will cost 3-5 sec),when the constructor of class RecordeDialog had executived,I hide the gif(label->hide()) and show the dialog(dialog->exec());
      But in fact ,when i executive the construct of class RecordeDialog,the gif will be stop..How to keep the GIF on running when dialog is executiving?

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 18 Oct 2018, 07:08 last edited by
      #2

      @qazaq408
      why does the dialog take such long time in it's constructor?
      You need to move the heavy processing into a separate thread and open the dialog once the data is ready.

      Your problem is that you put the heavy load on the UI thread (the default thread) which prevents further painting.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      Q 1 Reply Last reply 18 Oct 2018, 07:20
      6
      • R raven-worx
        18 Oct 2018, 07:08

        @qazaq408
        why does the dialog take such long time in it's constructor?
        You need to move the heavy processing into a separate thread and open the dialog once the data is ready.

        Your problem is that you put the heavy load on the UI thread (the default thread) which prevents further painting.

        Q Offline
        Q Offline
        qazaq408
        wrote on 18 Oct 2018, 07:20 last edited by
        #3

        @raven-worx said in How To "Loading"......:

        @qazaq408
        why does the dialog take such long time in it's constructor?
        You need to move the heavy processing into a separate thread and open the dialog once the data is ready.

        Your problem is that you put the heavy load on the UI thread (the default thread) which prevents further painting.

        1 The dialog need to read some pix that may be on the disk,and the pix used in medic so that it's always 10Mb or bigger...

        2 Wether the QLabel(play GIF) or QDialog,thet are all children of QWidget and only run on the main thread

        R 1 Reply Last reply 18 Oct 2018, 07:57
        0
        • Q qazaq408
          18 Oct 2018, 07:20

          @raven-worx said in How To "Loading"......:

          @qazaq408
          why does the dialog take such long time in it's constructor?
          You need to move the heavy processing into a separate thread and open the dialog once the data is ready.

          Your problem is that you put the heavy load on the UI thread (the default thread) which prevents further painting.

          1 The dialog need to read some pix that may be on the disk,and the pix used in medic so that it's always 10Mb or bigger...

          2 Wether the QLabel(play GIF) or QDialog,thet are all children of QWidget and only run on the main thread

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 18 Oct 2018, 07:57 last edited by
          #4

          @qazaq408 said in How To "Loading"......:

          Wether the QLabel(play GIF) or QDialog,thet are all children of QWidget and only run on the main thread

          i know. i said you should move just the processing to another thread.
          This means the loading of the image into memory. You cannot use QPixmap outside the ui thread. So you will need to use QImage.

          Also you are advised to think about some smart handling of such big image files.
          How exactly are you displaying/painting the image at the end?

          I think it's a good idea to paint the image by directly accessing it's bytedata and/or only painting and accessing the visible parts of the image.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          Q 1 Reply Last reply 18 Oct 2018, 08:08
          2
          • R raven-worx
            18 Oct 2018, 07:57

            @qazaq408 said in How To "Loading"......:

            Wether the QLabel(play GIF) or QDialog,thet are all children of QWidget and only run on the main thread

            i know. i said you should move just the processing to another thread.
            This means the loading of the image into memory. You cannot use QPixmap outside the ui thread. So you will need to use QImage.

            Also you are advised to think about some smart handling of such big image files.
            How exactly are you displaying/painting the image at the end?

            I think it's a good idea to paint the image by directly accessing it's bytedata and/or only painting and accessing the visible parts of the image.

            Q Offline
            Q Offline
            qazaq408
            wrote on 18 Oct 2018, 08:08 last edited by
            #5

            @raven-worx
            Thank you.
            In fact,I had got the question by load pix in child Thread.But I think there some widgets, that's maybe
            need to cost a little long time for construction.So,I'm very curious to konw how to use the "Loading.gif" when the widget is on the construction.,you konw,many software has the funtion look like this, and there software usually play a gif when a widget/dialog/others is launching.

            J.HilkJ 1 Reply Last reply 18 Oct 2018, 08:13
            0
            • Q qazaq408
              18 Oct 2018, 08:08

              @raven-worx
              Thank you.
              In fact,I had got the question by load pix in child Thread.But I think there some widgets, that's maybe
              need to cost a little long time for construction.So,I'm very curious to konw how to use the "Loading.gif" when the widget is on the construction.,you konw,many software has the funtion look like this, and there software usually play a gif when a widget/dialog/others is launching.

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on 18 Oct 2018, 08:13 last edited by
              #6

              @qazaq408
              there's also QPixmapCache, haven't used it yet, but that way you should be able to push the delay in the startup of your application or do it scattered for each Image, to prevent/reduce freezes


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              1

              1/6

              18 Oct 2018, 06:05

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved