Application is Closed
-
Hi All,
I've inserted an observer into my app that take a look to the camera folder, it's a feature, my real app is a cartographic app, but when i start camera my application is closed, it doesn't crash it simply closes and retrun 0 the ret value of exec() function.
Some of could give em an Hand?
thanks -
Which OS do you use? Symbian, Maemo?...
-
I'm working on Symbian OS
-
How do you use camera? QtMultimediaKit from QtMobility?
-
Can you post your main() function?
-
I'm using QFileSystemWatcher to understand when a new img is created into the default picture folder.
I've tried to use CCAmera and MCameraObserver2 but I had not any results... -
I'm specifically interested in how you're launching the actual "guts" of the program though; could you put it on Pastebin? I will be more able to help if I can see it... :)
-
Sorry but i'm not able to understand what do you wana see...
-
You should have a function somewhere with the prototype:
@int main (int argc, char* argv[])@That function is the one I want to see. If it's large (though it generally will not be for a Qt program), you could put it on Pastebin.
-
Just in case: "Pastebin":http://pastebin.com/ is a website where you can publish some snippets of code, so you can share them with others. You don't need to use it if you don't want to, just post here the code (mark it with "@" signs, so it will be formatted).
-
This is my main function:
@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);createDirs(); QPixmap pixmap(":/images/Default.png"); QSplashScreen splash(pixmap); splash.show(); QGraphicsScene *scene=new QGraphicsScene(0,0,SCREEN_WIDTH,SCREEN_HEIGHT); scene->setBackgroundBrush(QBrush(QPixmap(":images/backgroundTile.png"))); LeoGraphicsView *view=LeoGraphicsView::defaultView(); LeoGraphicsView::defaultView()->setScene(scene); LeoChartGraphicsObject* viewObject = LeoChartGraphicsObject::defaultChart(); scene->addItem(viewObject); view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QFrame* frame = new QFrame(view); frame->setGeometry(QRect(0, 0, SCREEN_WIDTH, 65)); frame->setStyleSheet(QString::fromUtf8("background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(97, 97, 97), stop: 0.5 rgb(33, 33, 33), stop: 0.51 rgb(27, 27, 27), stop: 1 rgb(0, 0, 0));")); frame->setFrameShape(QFrame::StyledPanel); frame->setFrameShadow(QFrame::Raised); QPushButton *zoomIn=new QPushButton(view); zoomIn->setGeometry(295,10,40,40); zoomIn->setFlat(true); zoomIn->setFocusPolicy(Qt::NoFocus); zoomIn->setStyleSheet("background-image: url(:/images/ImmaginePiu.png);"); QObject::connect(zoomIn,SIGNAL(clicked()),viewObject,SLOT(zoomInSlot())); QPushButton *zoomOut=new QPushButton(view); zoomOut->setGeometry(235,10,40,40); zoomOut->setFlat(true); zoomOut->setFocusPolicy(Qt::NoFocus); zoomOut->setStyleSheet("background-image: url(:/images/ImmagineMeno.png);"); QObject::connect(zoomOut,SIGNAL(clicked()),viewObject,SLOT(zoomOutSlot())); QPushButton *cameraBtn=new QPushButton(view); cameraBtn->setGeometry(15,15,44,36); cameraBtn->setFlat(true); cameraBtn->setFocusPolicy(Qt::NoFocus); cameraBtn->setStyleSheet("background-image: url(:/images/BarCamera.png);"); cameraBtn->setHidden(true); QObject::connect(cameraBtn,SIGNAL(clicked()),viewObject,SLOT(cameraSlot())); QPushButton *menuBtn=new QPushButton(view); menuBtn->setGeometry(5,577,112,52); menuBtn->setFlat(true); menuBtn->setFocusPolicy(Qt::NoFocus); menuBtn->setStyleSheet("QPushButton { background-image: url(:/images/menu.png);}QPushButton:pressed { background-image: url(:/images/menu1.png);}"); QObject::connect(menuBtn,SIGNAL(clicked()),viewObject,SLOT(showMenu())); QMainWindow *mainWindow=new QMainWindow; mainWindow->setGeometry(0,0,SCREEN_WIDTH,SCREEN_HEIGHT); mainWindow->setWindowState(Qt::WindowFullScreen); mainWindow->setCentralWidget(view); mainWindow->show(); LeoWarningWidget* wdtWarning = new LeoWarningWidget(); wdtWarning->show(); splash.finish(mainWindow); int nVal = a.exec(); if(nVal == 0) { delete wdtWarning; wdtWarning = 0; delete zoomIn; zoomIn = 0; delete zoomOut; zoomOut = 0; delete cameraBtn; cameraBtn = 0; delete menuBtn; menuBtn = 0; delete frame; frame = 0; delete viewObject; viewObject = 0; delete view; view = 0; delete scene; scene = 0; delete mainWindow; mainWindow = 0; } qDebug() << "End of App"; return nVal;
}
@
Thanks for all -
Well, a few notes...
You don't need to delete all those classes near the end; since you've created the objects parented to the QMainWindow, it will handle the cleanup of those classes when the QMainWindow is destroyed.
Take a look at the example for QSplashScreen in the Qt documentation. You need to call QApplication::processEvents() after splash.show() so that the splash screen is actually displayed, since the application's message loop has not been started yet.
You may want to add some breakpoints or qDebug() calls in your LeoGraphicsView class to make sure it is actually getting shown - perhaps in showEvent(), and perhaps also in closeEvent(). If it is getting closed by something, do the same elsewhere in your code to see where/why that's happening.
Post a response here if the initial stuff doesn't help any.
You also may want to check the console output of Qt; it often displays helpful messages if there are issues at runtime.