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
11 replies
Just in case: Pastebin [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[])
- {
- createDirs();
- splash.show();
- LeoGraphicsView *view=LeoGraphicsView::defaultView();
- LeoGraphicsView::defaultView()->setScene(scene);
- LeoChartGraphicsObject* viewObject = LeoChartGraphicsObject::defaultChart();
- scene->addItem(viewObject);
- 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));"));
- zoomIn->setGeometry(295,10,40,40);
- zoomIn->setFlat(true);
- zoomIn->setStyleSheet("background-image: url(:/images/ImmaginePiu.png);");
- zoomOut->setGeometry(235,10,40,40);
- zoomOut->setFlat(true);
- zoomOut->setStyleSheet("background-image: url(:/images/ImmagineMeno.png);");
- cameraBtn->setGeometry(15,15,44,36);
- cameraBtn->setFlat(true);
- cameraBtn->setStyleSheet("background-image: url(:/images/BarCamera.png);");
- cameraBtn->setHidden(true);
- menuBtn->setGeometry(5,577,112,52);
- menuBtn->setFlat(true);
- menuBtn->setStyleSheet("QPushButton { background-image: url(:/images/menu.png);}QPushButton:pressed { background-image: url(:/images/menu1.png);}");
- mainWindow->setGeometry(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
- 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.
You must log in to post a reply. Not a member yet? Register here!





