You are on page 1of 1

main.cpp #include <QtGui/QApplication> #include "widget.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.

show(); } widget.cpp #include "widget.h" #include "cv.h" #include "highgui.h" #include <QtGui> Widget::Widget() { setGeometry(100,100,512,512); b1 = new QPushButton("Show Image",this); connect(b1,SIGNAL(clicked()), this, SLOT(slot_imgshow())); } void Widget::slot_imgshow() { //QMessageBox::information(this,"title","Hello this is popup"); img = cvLoadImage("/home/guest/bmp_output_101.bmp",0); //create a new window cvNamedWindow("Window", 1); //display the image in the window cvShowImage("Window", img); //wait for key to close the window cvWaitKey(0); cvDestroyWindow( "Window" ); //destroy the window } widget.h #ifndef WIDGET_H #define WIDGET_H #include <QtGui/QWidget> #include <QtGui> #include "cv.h" #include "highgui.h" class Widget : public QWidget { Q_OBJECT public: Widget(); QPushButton *b1; IplImage *img; public slots: void slot_imgshow(); }

You might also like