www.pudn.com > snake_vc++.rar > MainProgram.cpp


// Qt includes 
#include  
 
// local includes 
#include "MainProgram.h" 
#include "MainWindow.h" 
#include "QtCvWrapper.h" 
 
//////////////////////////////////////////////////////////////////////////// 
MainProgram::MainProgram(int argc, char* argv[]) 
{ 
	// create a new instance of QApplication with params argc and argv 
	QApplication app( argc, argv ); 
	// create a new instance of MainWindow with no parent widget 
	m_mainWindow = new MainWindow(0, Qt::Window); 
	// The main widget is like any other, in most respects except that if it is deleted, 
	// the application exits. 
	app.setActiveWindow(m_mainWindow); 
	// set the application style 
	app.setStyle("plastique"); 
	// resize window to 800x600 (including the 512x512 image space) 
	m_mainWindow->resize(800,530); 
	// Shows the widget and its child widgets. 
	m_mainWindow->show(); 
 
	m_wrapper = new QtCvWrapper(this, m_mainWindow); 
 
	// connections between gui and not-gui 
	QObject::connect(m_mainWindow, SIGNAL(signalSnakeButtonPressed()), m_wrapper, SLOT(slotSnakeButtonPressed())); 
	QObject::connect(m_mainWindow, SIGNAL(signalDemoButtonPressed()), m_wrapper, SLOT(slotTest())); 
	QObject::connect(m_mainWindow, SIGNAL(signalImageOpened()), m_wrapper, SLOT(slotImageOpened())); 
	QObject::connect(m_mainWindow, SIGNAL(signalInitCurve()), m_wrapper, SLOT(slotInitCurve())); 
	// iteration on/off 
	QObject::connect(m_mainWindow, SIGNAL(signalIterationOn()), m_wrapper, SLOT(slotIterationOn())); 
	QObject::connect(m_mainWindow, SIGNAL(signalIterationOff()), m_wrapper, SLOT(slotIterationOff())); 
	QObject::connect(m_mainWindow, SIGNAL(signalIterationStep()), m_wrapper, SLOT(slotIterationStep())); 
 
 
 
	 
 
	// Enters the main event loop and waits until exit() is called 
	// or the main widget is destroyed, and returns the value that 
	// was set via to exit() (which is 0 if exit() is called via quit()). 
	app.exec(); 
} 
 
//////////////////////////////////////////////////////////////////////////// 
MainProgram::~MainProgram(void) 
{ 
}