Results 1 to 8 of 8

Thread: How to increase progress bar

  1. #1
    Join Date
    Dec 2012
    Posts
    45
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default How to increase progress bar

    I want too set progress bar in my Ui which increases as my code is being processed.

    I am doing heavy calculation in my code to calculate the X and Y cordinates which freezes my ui for few second and i want to use progress bar to be filled in that duration any idea

  2. #2
    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: How to increase progress bar

    You need to process events after you change the progress bar value. Alternatively you can execute your heavy calculations in a worker thread so that the UI thread remain responsive. Also see this article -- [wiki]Keeping the GUI Responsive[/wiki]
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2012
    Posts
    45
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: How to increase progress bar

    thanks a lot for the idea and can you tell me if i put my heavy calculation part on worker thread will it improve the performance? right now its taking around 5 second to calculate 5 billion points

  4. #4
    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: How to increase progress bar

    Quote Originally Posted by shivendra46d View Post
    thanks a lot for the idea and can you tell me if i put my heavy calculation part on worker thread will it improve the performance? right now its taking around 5 second to calculate 5 billion points
    No, it will not improve performance. Only modification of the algorithm (e.g. concurrent calculation on multiple threads) might do that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2012
    Posts
    45
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: How to increase progress bar

    Thanks i did the same that you told and it worked. Also Regarding progress bar i used signals and slot it was easy and better.
    Now i want to ask that i am using LinearGradient to draw line with color gradient. So it is drawing but the gradient colors are varrying by height of my widget but what i want is it to varry by width of my widget
    " QLinearGradient linearGrad;
    linearGrad.setCoordinateMode(QGradient::StretchToD eviceMode);
    linearGrad.setStart( 0.0, 0.0 );
    linearGrad.setFinalStop( 0.0, 1.0 );
    linearGrad.setColorAt(1.0, QColor(0,0,255));
    linearGrad.setColorAt(0.3, QColor(147,0,0));
    linearGrad.setColorAt(0.0, Qt::red);

    PrivewPainter.setPen(QPen(linearGrad,1));


    for (int i =0; i<static_cast<int>(SRP_Widget_Width)-1; i++)
    {
    for (int j =0 ; j<static_cast<int>(SRP_Widget_Height)-1; j++)
    {
    if(Total_Intensity[j][i] !=0)
    {


    PrivewPainter.drawLine(i,j,i+1,j+1) ;


    }
    }
    }"
    here is my code in This Total_Intensity is a 2d vector

  6. #6
    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: How to increase progress bar

    Change coordinates of the final stop from 0,1 to 1,0.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    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: How to increase progress bar

    The distribution direction is easier to see if you pass the values to the constructor

    Qt Code:
    1. QLinearGradient grad1( 0, 0, width(), 0 ); // distribute colors over width of widget
    2. QLinearGradient grad1( 0, 0, 0, height() ); // distribute colors over height of widget
    3. QLinearGradient grad1( 0, 0, width(), height() ); // distribute colors over width and height of widget, diagonally
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  8. #8
    Join Date
    Dec 2012
    Posts
    45
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: How to increase progress bar

    Thanks guys you both helped me a lot.

Similar Threads

  1. memory increase when use PageStack
    By jindoniit in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 13th October 2011, 11:23
  2. how to increase the transparency of Qpainter?
    By athulms in forum Qt Programming
    Replies: 0
    Last Post: 16th August 2011, 06:16
  3. increase the size of my plot
    By 21did21 in forum Qwt
    Replies: 4
    Last Post: 29th May 2011, 11:03
  4. How to increase available RAM for Qt Creator?
    By fezvez in forum Qt Tools
    Replies: 4
    Last Post: 19th April 2011, 21:37
  5. Replies: 4
    Last Post: 11th March 2008, 11:44

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.