• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

examples/example7/example7.cpp

Go to the documentation of this file.
00001 
00003 #include <QApplication>
00004 #include <QPushButton>
00005 #include <QHBoxLayout>
00006 #include <QVBoxLayout>
00007 #include <QSlider>
00008 
00009 #include "OverlayWidget.h"
00010 
00011 #include "CameraThread.h"
00012 
00013 /***********************************************************/
00014 /* Full camera application                                 */
00015 /*                                                         */
00016 /* This example uses QT to create a full camera            */
00017 /* application for the N900. It displays viewfinder frames */
00018 /* using an fbdev overlay.                                 */
00019 /***********************************************************/
00020 
00021 int main(int argc, char **argv) {
00022     QApplication app(argc, argv);
00023 
00024     // Make the main window and a layout for it
00025     QWidget *window = new QWidget;
00026     QHBoxLayout *layout = new QHBoxLayout;
00027     layout->setContentsMargins(0, 0, 0, 0);
00028 
00029     // Put a slider on the left
00030     QSlider *slider = new QSlider(Qt::Vertical);
00031     layout->addWidget(slider);
00032 
00033     // Make an overlay for displaying viewfinder frames
00034     OverlayWidget *overlay = new OverlayWidget(window);
00035     overlay->setFixedSize(640, 480);
00036     layout->addWidget(overlay);
00037 
00038     // Make some buttons down the right
00039     QVBoxLayout *buttonLayout = new QVBoxLayout;
00040     layout->addLayout(buttonLayout);
00041     QPushButton *quitButton = new QPushButton("X");
00042     QPushButton *button1 = new QPushButton("1");
00043     QPushButton *button2 = new QPushButton("2");
00044     QPushButton *button3 = new QPushButton("3");
00045     quitButton->setFixedSize(80, 64);
00046     button1->setFixedSize(80, 64);
00047     button2->setFixedSize(80, 64);
00048     button3->setFixedSize(80, 64);
00049     buttonLayout->addWidget(quitButton);
00050     buttonLayout->addStretch(1);
00051     buttonLayout->addWidget(button1);
00052     buttonLayout->addWidget(button2);
00053     buttonLayout->addWidget(button3);
00054 
00055     window->setLayout(layout);
00056 
00057     // Make a thread that controls the camera
00058     CameraThread cameraThread(overlay);
00059 
00060     // Hook up the quit button to stop the camera thread
00061     QObject::connect(quitButton, SIGNAL(clicked()), 
00062                      &cameraThread, SLOT(stop()));
00063 
00064     // Once the camera thread stops, quit the app
00065     QObject::connect(&cameraThread, SIGNAL(finished()), 
00066                      &app, SLOT(quit()));
00067 
00068     // Show the app full screen
00069     window->showFullScreen();
00070 
00071     // Launch the camera thread
00072     cameraThread.start();
00073 
00074     // Enter the QT main event loop
00075     return app.exec();
00076 }

Generated on Mon Aug 16 2010 14:25:45 for FCam by  doxygen 1.7.1