本文整理汇总了C++中TcpServer::startServer方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpServer::startServer方法的具体用法?C++ TcpServer::startServer怎么用?C++ TcpServer::startServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpServer
的用法示例。
在下文中一共展示了TcpServer::startServer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
TcpServer *server = new TcpServer(2);
server->startServer();
return a.exec();
}
示例2: main
/**
* @brief main main method to create application
* @param argc count of elements in argv
* @param argv include all commando line parameter
* @return Return 0 if ok otherwise a error code not equal 0
*/
int main(int argc, char *argv[])
{
QCoreApplication::setOrganizationName("GUI-Frameworks");
QCoreApplication::setApplicationName("HeartRate");
QApplication app(argc, argv);
app.setWindowIcon(QIcon(":/Images/heart_icon.png"));
//multiple language
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&qtTranslator);
QTranslator myappTranslator;
myappTranslator.load(":/Language_Files/app_" + QLocale::system().name() + ".qm");
app.installTranslator(&myappTranslator);
Settings& settings = Settings::getInstance();
if (!settings)
{
qDebug("FATAL error while instanciating Settings!!");
return 1;
}
/******************************************
* instanciate dataStorage
* has to be referenced to the model
* which need the data
*******************************************/
ImportExport dataStorage;
if (!dataStorage)
{
qDebug("FATAL error while creating Database instance");
return 1;
}
BroadcastReceiver bcReceiver;
// run broadcast receiver thread loop:
bcReceiver.start();
TcpServer server;
// listen for incoming data connections:
server.startServer();
// create sensorInactiveData Model
SensorModel inactiveSensorModel;
// create inactiveCalcSensorModel
InactiveSensorCalcModel inactiveCalcSensorModel(inactiveSensorModel);
// create sensorActiveModel
SensorModel activeSensorModel;
// create sensorActiveTable Model
SensorModel activeSensorTableModel;
// create activeCalcSensorModel
ActiveSensorCalcModel activeCalcSensorModel(activeSensorModel);
// create selectionValue models
SelectionModel activeYearModel, activeMonthModel;
qmlRegisterType<CustomPlotBarChart>("CostumPlot", 1, 0, "CustomPlotBarChart");
qmlRegisterType<CustomPlotLineChart>("CostumPlot", 1, 0, "CustomPlotLineChart");
QQmlApplicationEngine engine;
QQmlContext* contex = engine.rootContext();
if(contex)
{
// set Model to view
contex->setContextProperty("inactiveSensorDataModel", &inactiveSensorModel);
contex->setContextProperty("activeSensorDataModel", &activeSensorModel);
contex->setContextProperty("inactiveSensorCalcModel", &inactiveCalcSensorModel);
contex->setContextProperty("activeSensorCalcModel", &activeCalcSensorModel);
contex->setContextProperty("activeSelectionYearModel", &activeYearModel);
contex->setContextProperty("activeSelectionMonthModel", &activeMonthModel);
contex->setContextProperty("activeSensorTableModel", &activeSensorTableModel);
}
else qDebug() << "Error no contex is set";
// load qml file to engine
engine.load(QUrl(MAIN_VIEW));
QObject* root = engine.rootObjects().at(0);
if(root)
{
// initate tabs
QObject* tabView = root->findChild<QObject*>("TabViewName");
if(tabView)
{
const int countTabs = tabView->property("count").toInt();
for(int i = countTabs-1 ; i >= 0; i--)
{
//.........这里部分代码省略.........