//main.cpp File
#include "myWindow.h"

int main(int argc, char **argv)
{
	QApplication app(argc, argv);

	MyWindow *window = new MyWindow();    
    
        window->setWindowTitle(QString::fromUtf8("Enjoyable QProgessBar Example"));
        window->resize(336, 227);
	
	window->show();
	return app.exec();
}
//mywindow.h File

#ifndef MYWINDOW_H
#define MYWINDOW_H
#include<QtGui>

class MyWindow: public QMainWindow
{
  Q_OBJECT
  
  public:    
	MyWindow()
	{	  
	  QWidget *centralWidget = new QWidget(this);
	  setCentralWidget(centralWidget);
	  
	  QHBoxLayout *layout = new QHBoxLayout();  
	  centralWidget->setLayout(layout);  
	  
	  slider	= new QSlider();
	  progressbar 	= new QProgressBar();
	  
	  
	  //Add Widgets to horizontal layout
	  layout->addWidget(slider);
	  layout->addWidget(progressbar);	  
	  
	  QObject::connect(slider,SIGNAL(valueChanged(int)),this,SLOT(valueChangedSlot(int)));
	};
	~ MyWindow(){};
	
  public slots: 
    void valueChangedSlot(int value)
    {
      progressbar->setValue(value);
    };
  
  public:
    QSlider* slider;
    QProgressBar* progressbar;
};
#endif