Results 1 to 20 of 35

Thread: busy progress bar without thread ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Posts
    53
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Smile busy progress bar without thread ?

    Hi,

    I am using progress bar which showing a busy mode ( minimum = maximum = 0 ).
    and my code goes like this..

    Qt Code:
    1. progressBar.setMinimum(0);
    2. progressBar.setMaximum(0);
    3. fn();
    4. progressBar.hide();
    To copy to clipboard, switch view to plain text mode 

    When the process running in fn() the progress bar is not showing the busy mode.

    But I want to show the progressbar in a busy mode till the fn retuns.
    should I use threads for this ? or is there any easy way ?

    Thanks
    *npc*

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: busy progress bar without thread ?

    you should call the progress bar in your fn() function.
    Show your fn() fucntion code.

  3. #3
    Join Date
    Mar 2006
    Posts
    53
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: busy progress bar without thread ?

    It is a big code which is used to collect the system informations.

    I called the progress bar in fn() like this

    Qt Code:
    1. fn()
    2. {
    3.  
    4. fn1();
    5. prgressBar.show();
    6. fn2();
    7. progressBar.show();
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    But it doesnt helps me

    Thanks,
    *npc*

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: busy progress bar without thread ?

    but where do you call setValue()?

  5. #5
    Join Date
    Mar 2006
    Posts
    53
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: busy progress bar without thread ?

    Because I want to show busy indicator in progress bar, I set minimum and maximum values as 0.

    So what is the need of calling setvalue ? ..if it necessary what value have to send ?

    Thanks,
    *npc*

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: busy progress bar without thread ?

    Well lets see -
    How can the progress bar know, when to progress the bar?
    I suggest you read the docs first:
    http://doc.trolltech.com/4.2/qprogressbar.html

  7. #7
    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: busy progress bar without thread ?

    I think you're missing some QCoreApplication::processEvents() calls...

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

    npc (31st March 2007)

  9. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: busy progress bar without thread ?

    Wysota - I think so too, but even that wont help if he doesen't call setValue()...

  10. #9
    Join Date
    Mar 2006
    Posts
    53
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: busy progress bar without thread ?

    I think you're missing some QCoreApplication:rocessEvents() calls...
    Exactly.. Thanks Wysota.

    Now its working fine for me.. I called QCoreApplication:rocessEvents() in sub functions.

    But I never called setValue() anywhere

  11. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: busy progress bar without thread ?

    So how is the progress bar incremented?
    The progress bar uses the concept of steps. You set it up by specifying the minimum and maximum possible step values, and it will display the percentage of steps that have been completed when you later give it the current step value. The percentage is calculated by dividing the progress (value() - minimum()) divided by maximum() - minimum().

  12. #11
    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: busy progress bar without thread ?

    It's not, it's just spinning all the time like in Star Trek or Knightrider. This is a special case of using a progress bar that is activated by setting the range of values to [0,0].

Similar Threads

  1. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  2. simple thread layout question
    By mhoover in forum Qt Programming
    Replies: 1
    Last Post: 12th August 2006, 11:02
  3. Replies: 11
    Last Post: 7th July 2006, 13:09
  4. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44
  5. Replies: 2
    Last Post: 6th January 2006, 21:15

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.