car_deal_util/code/cpp/car_dealer_util/source/main.cpp

117 lines
2.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <QtWidgets/QtWidgets>
#include <QtWidgets/QApplication>
#include <stdexcept>
#include "Widgets/MainFrame/QMainFrame.h"
#include "QLoginDialog.h"
#include "Data/Datastructure/CarDealer/CarDealerMap.h"
#include "test/test.h"
using namespace std;
int main( int argc, char * argv[] )
{
QApplication * pApp = nullptr;
QMainFrame * pMainFrame = nullptr;
QLoginDialog * pLoginDialog = nullptr;
int returnCode = -1;
try
{
pApp = new QApplication( argc, argv );
}
catch ( ... )
{
QMessageBox::critical( nullptr,
"错误!",
"1创建QApplication错误\n请联系开发人员。" );
return -1;
}
test();
//return 1;
//加载资源
try
{
InitCarDealerMap();
}
catch ( runtime_error & error )
{
QMessageBox::critical( nullptr,
"错误!",
error.what() );
return -1;
}
//登录界面
try
{
pLoginDialog = new QLoginDialog();
pLoginDialog->exec();
if ( pLoginDialog->getReturnCode() == QLoginDialog::ReturnCode::EXIT )
{
//用户点了退出
return 1;
}
}
catch ( std::runtime_error error )
{
QMessageBox::critical( nullptr,
"错误!",
error.what() );
return -1;
}
try
{
pMainFrame = new QMainFrame();
}
catch ( std::runtime_error & error )
{
QMessageBox::critical( nullptr,
"错误!",
error.what() );
return -1;
}
catch ( ... )
{
QMessageBox::critical( nullptr,
"错误!",
"创建窗口过程错误!\n请联系开发人员。" );
return -1;
}
try
{
pMainFrame->showMaximized();
returnCode = pApp->exec();
}
catch ( std::runtime_error & error )
{
QMessageBox::critical( nullptr,
"错误!",
error.what() );
return -1;
}
catch ( ... )
{
QMessageBox::critical( nullptr,
"错误!",
"创建窗口过程错误!\n请联系开发人员。" );
return -1;
}
return returnCode;
}