Dear visitor who can read English
This page is a page translated automatically by Google AJAX Language API.
Please comment to this page if you could not understand. A PERSON will review this page .
I think that you will be able to understand this page later. Please give a little time to us.
Best regards,
This site is support & information site of WEB,and Software. This site might help you that create software or Web Site…perhaps?[:]
Summary: This time, Qt marquee explains the progress bar to show how easily.
and marquee, WindowsXP from the startup screen after the progress bar, rather than to build up, and the show flowing now is to show progress.
This marquee (see propaganda) and the colors that we have referred.
indeterminate (in the effective running I do not know how much), barber-pole (barber's pole), spinning bar (a bar that spins round and round) and so on.
(Web on, barber-pole like a major but, here, marquee Make a uniform.
() Is a literal translation in Japanese.
I tried to describe what I felt better somehow, I'll understand.
)
Came to the Windows API that is compatible with, it is not too old.
This time, Qt uses a sample that is provided in the marquee we'll see.
Immediately, let's use the sample display
The sample used here is a sample of the progress bar.
Usually located in the directory below.
% Qt installation directory% \ qt \ examples \ qtconcurrent \ progressdialog The following is the main.cpp.
[main.cpp]
usingnamespace QtConcurrent;constint iterations =20;void spin(int&iteration){constint work =1000*1000*40;volatileint v =0;for(int j =0; j < work;++j)++v;qDebug()<<"iteration"<< iteration <<"in thread"<<QThread::currentThreadId();}int main(int argc,char**argv){QApplication app(argc, argv);// Prepare the vector.QVector<int> vector;for(int i =0; i < iterations;++i)
vector.append(i);// Create a progress dialog.QProgressDialog dialog;
dialog.setLabelText(QString("Progressing using %1 thread(s)...").arg(QThread::idealThreadCount()));// Create a QFutureWatcher and conncect signals and slots.QFutureWatcher<void> futureWatcher;QObject::connect(&futureWatcher,SIGNAL(finished()),&dialog,SLOT(reset()));QObject::connect(&dialog,SIGNAL(canceled()),&futureWatcher,SLOT(cancel()));QObject::connect(&futureWatcher,SIGNAL(progressRangeChanged(int,int)),&dialog,SLOT(setRange(int,int)));QObject::connect(&futureWatcher,SIGNAL(progressValueChanged(int)),&dialog,SLOT(setValue(int)));// Start the computation.
futureWatcher.setFuture(QtConcurrent::map(vector, spin));// Display the dialog and start the event loop.
dialog.exec();
futureWatcher.waitForFinished();// Query the future to check if was canceled.qDebug()<<"Canceled?"<< futureWatcher.future().isCanceled();}
QFutureWatcher contains a description of the class so little that is complex, doing that is simple.
QFutureWatcher with class, causing the thread, QProgressDialog class by calling setValue to 20 times in a row.
5 from the first line, spin functions are called.
This function is called 20 times.
Dzutsude times that one is a demonstration of the long processing functions.
After calling this function, QFutureWatcher progressValueChanged class and causing a signal.
progressValueChanged received signals, QProgressDialog the setValue progress bar is displayed in the switch mechanism.
The following screen appears when you run, the progress bar reaches 100% and then to automatically terminate.
Switch Qt to display a progress bar in marquee is easy.
Main.cpp 32 just above the following changes to the line.
[main.cpp]
It is easy.
The range of 0 and would progress to switch to fixed marquee display.
This marquee display, Windows2000 You can view as well.
(95 systems do not know.
) In addition, the document is likely since there is no notation, and possibly, may not be a formal response, on the understanding, please do not use.
(At least at work 4.5.1,4.5.2 was the same.
)
Once you know, I do wonder if the author is to arrive in this way, very, took a long time.
A little, but this article, I hope to help you if.
Leave a Reply