RE: Gtk::ProgressBar is not being updated inside a for statement



> void wait(double seconds){
> clock_t end_wait;
> end_wait = clock () + end_wait * CLOCKS_PER_SEC ;
> while (clock() < end_wait) {}
> }
>
> for(int i=1; i<=max_time; i++){
>
> wait(1); //Waits one second
>
> myProgressBar.set_fraction(i/max_time); //it updates the
> GUI until it has returned to the main window loop
>
> while(Gtk::Main::events_pending()) //this should update
> the progress bar in GUI on each iteration in this for statement, but it
> doesn't
>
> Gtk::Main::iteration();//I tried both arguments, false
> and true, none of them worked, same result... it gets updated when it
> exits the function that uses this for statement
> }

You should put the Gtk::Main::iteration() inside the while loop:

while(Gtk::Main::events_pending())
{
   Gtk::Main::iteration();
}


Με το Windows Live, μπορείτε να οργανώνετε, να επεξεργάζεστε και να μοιράζεστε τις φωτογραφίες σας.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]