****************************************************************************/
#ifndef FORM1_H
#define FORM1_H
#include <qdialog.h>
#include <qtimer.h>
{
Q_OBJECT
public:
Form1
( QWidget* parent
= 0,
const char* name
= 0,
bool modal
= FALSE, WFlags fl
= 0 );
~Form1();
protected slots:
void myiter();
void mystart();
};
#endif // FORM1_H
****************************************************************************/
#include "form1.h"
#include <qpushbutton.h>
#include <qprogressbar.h>
#include <qtimer.h>
Form1
::Form1( QWidget* parent,
const char* name,
bool modal, WFlags fl
) : QDialog( parent, name, modal, fl
){
pb
->setGeometry
( QRect( 100,
0,
500,
30 ) );
pb->setTotalSteps( 10 );
pb->reset();
connect( sb, SIGNAL( clicked() ), this, SLOT( mystart() ) );
connect( &timer, SIGNAL( timeout() ), this, SLOT( myiter() ) );
}
Form1::~Form1() {};
void Form1::mystart() { if ( !timer.isActive() ) { timer.start(400); } else { timer.stop(); } }
void Form1::myiter() { int i = pb->progress(); pb->setProgress( ++i ); }
#include <qapplication.h>
#include "form1.h"
****************************************************************************/
int main( int argc, char ** argv )
{
Form1 w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
****************************************************************************/
#ifndef FORM1_H
#define FORM1_H
#include <qdialog.h>
#include <qtimer.h>
class QProgressBar;
class QPushButton;
class Form1 : public QDialog
{
Q_OBJECT
public:
Form1( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~Form1();
QPushButton *sb;
QProgressBar* pb;
QTimer timer;
protected slots:
void myiter();
void mystart();
};
#endif // FORM1_H
****************************************************************************/
#include "form1.h"
#include <qpushbutton.h>
#include <qprogressbar.h>
#include <qtimer.h>
Form1::Form1( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl )
{
sb = new QPushButton( "&Start", this );
pb = new QProgressBar( this );
pb->setGeometry( QRect( 100, 0, 500, 30 ) );
pb->setTotalSteps( 10 );
pb->reset();
connect( sb, SIGNAL( clicked() ), this, SLOT( mystart() ) );
connect( &timer, SIGNAL( timeout() ), this, SLOT( myiter() ) );
}
Form1::~Form1() {};
void Form1::mystart() { if ( !timer.isActive() ) { timer.start(400); } else { timer.stop(); } }
void Form1::myiter() { int i = pb->progress(); pb->setProgress( ++i ); }
#include <qapplication.h>
#include "form1.h"
****************************************************************************/
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
Form1 w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks