From df7ce85939f871d4391f5610cee0790dc8bb16b8 Mon Sep 17 00:00:00 2001 From: birkeh Date: Thu, 9 Feb 2017 14:30:37 +0100 Subject: [PATCH] init --- Kooky/cimportingredientdialog.cpp | 2 +- Kooky/cingredient.cpp | 13 +++ Kooky/cingredient.h | 1 + Kooky/cmainwindow.cpp | 156 +++++++++++++++++++++++++++--- Kooky/cmainwindow.h | 14 +++ Kooky/cmainwindow.ui | 26 +++-- Kooky/cmdiarea.h | 2 + Kooky/cmessageanimatedialog.cpp | 2 +- Kooky/coptions.cpp | 6 +- Kooky/coptionsplugins.cpp | 6 +- dSQLite/csqliteplugin.cpp | 11 ++- iBleibFit/cbleibfitplugin.cpp | 4 +- 12 files changed, 207 insertions(+), 36 deletions(-) diff --git a/Kooky/cimportingredientdialog.cpp b/Kooky/cimportingredientdialog.cpp index dae4d02..dc78379 100644 --- a/Kooky/cimportingredientdialog.cpp +++ b/Kooky/cimportingredientdialog.cpp @@ -34,7 +34,7 @@ void cImportIngredientDialog::initIngredientList() { m_lpIngredientListModel = new QStandardItemModel(0, 1); ui->m_lpIngredientList->setModel(m_lpIngredientListModel); - connect(ui->m_lpIngredientList->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(onIngredientListSelectionChanged(QItemSelection,QItemSelection))); + connect(ui->m_lpIngredientList->selectionModel(), &QItemSelectionModel::selectionChanged, this, &cImportIngredientDialog::onIngredientListSelectionChanged); } m_lpIngredientListModel->clear(); } diff --git a/Kooky/cingredient.cpp b/Kooky/cingredient.cpp index c88aac8..cd336e3 100644 --- a/Kooky/cingredient.cpp +++ b/Kooky/cingredient.cpp @@ -345,11 +345,24 @@ QString cIngredient::valueFormatted(cIngredient::iIngredient i) } } break; + default: + str = QString("%1").arg(dValue); + break; } return(str); } +cIngredient::MEASURE cIngredient::measure(cIngredient::iIngredient i) +{ + for(int z = 0;z < (int)sizeof(g_groupname)/(int)sizeof(GROUPNAME);z++) + { + if(g_groupname[z].iIngredient == i) + return(g_groupname[z].measure); + } + return(cIngredient::MEASURE::MEASURE_None); +} + void cIngredient::setValue(cIngredient::iIngredient i, qreal dValue) { m_dValue[i] = dValue; diff --git a/Kooky/cingredient.h b/Kooky/cingredient.h index 6004218..03c18e2 100644 --- a/Kooky/cingredient.h +++ b/Kooky/cingredient.h @@ -219,6 +219,7 @@ public: void setValue(cIngredient::iIngredient i, qreal dValue); qreal value(cIngredient::iIngredient i); QString valueFormatted(cIngredient::iIngredient i); + MEASURE measure(cIngredient::iIngredient i); /*! \brief diff --git a/Kooky/cmainwindow.cpp b/Kooky/cmainwindow.cpp index 181b252..6a576f2 100644 --- a/Kooky/cmainwindow.cpp +++ b/Kooky/cmainwindow.cpp @@ -34,7 +34,14 @@ cMainWindow::cMainWindow(QWidget *parent) : m_lpIngredientsListEdit(0), m_lpIngredientsListMenu(0), m_lpDB(0), - m_szLastImportPlugin("") + m_szLastImportPlugin(""), + m_lpWindowMenuCloseAct(0), + m_lpWindowMenuCloseAllAct(0), + m_lpWindowMenuTileAct(0), + m_lpWindowMenuCascadeAct(0), + m_lpWindowMenuNextAct(0), + m_lpWindowMenuPreviousAct(0), + m_lpWindowMenuSeparatorAct(0) { QThread::msleep(2000); init(); @@ -76,28 +83,32 @@ void cMainWindow::init() ui->m_lpIngredientsList->header()->setStretchLastSection(false); ui->m_lpIngredientsList->header()->setSectionResizeMode(0, QHeaderView::Stretch); - connect(ui->m_lpMenu_File_Exit, SIGNAL(triggered(bool)), this, SLOT(menuFileExitTriggered())); - connect(ui->m_lpMenu_Tools_Options, SIGNAL(triggered(bool)), this, SLOT(menuToolsOptionsTriggered())); + connect(ui->m_lpMenu_File_Exit, &QAction::triggered, this, &cMainWindow::menuFileExitTriggered); + connect(ui->m_lpMenu_Tools_Options, &QAction::triggered, this, &cMainWindow::menuToolsOptionsTriggered); ui->m_lpIngredientsList->setContextMenuPolicy(Qt::CustomContextMenu); - connect(ui->m_lpIngredientsList, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ingredientsListCustomContextMenu(const QPoint &))); + connect(ui->m_lpIngredientsList, &QTreeView::customContextMenuRequested, this, &cMainWindow::ingredientsListCustomContextMenu); m_lpIngredientsListMenu = new QMenu(ui->m_lpIngredientsList); m_lpIngredientsListNew = new QAction("&New", m_lpIngredientsListMenu); m_lpIngredientsListMenu->addAction(m_lpIngredientsListNew); - connect(m_lpIngredientsListNew, SIGNAL(triggered(bool)), this, SLOT(ingredientsListNewTriggered())); + connect(m_lpIngredientsListNew, &QAction::triggered, this, &cMainWindow::ingredientsListNewTriggered); m_lpIngredientsListImport = new QAction("&Import", m_lpIngredientsListMenu); m_lpIngredientsListMenu->addAction(m_lpIngredientsListImport); - connect(m_lpIngredientsListImport, SIGNAL(triggered(bool)), this, SLOT(ingredientsListImportTriggered())); + connect(m_lpIngredientsListImport, &QAction::triggered, this, &cMainWindow::ingredientsListImportTriggered); m_lpIngredientsListDelete = new QAction("&Delete", m_lpIngredientsListMenu); m_lpIngredientsListMenu->addAction(m_lpIngredientsListDelete); - connect(m_lpIngredientsListDelete, SIGNAL(triggered(bool)), this, SLOT(ingredientsListDeleteTriggered())); + connect(m_lpIngredientsListDelete, &QAction::triggered, this, &cMainWindow::ingredientsListDeleteTriggered); m_lpIngredientsListEdit = new QAction("&Edit", m_lpIngredientsListMenu); m_lpIngredientsListMenu->addAction(m_lpIngredientsListEdit); - connect(m_lpIngredientsListEdit, SIGNAL(triggered(bool)), this, SLOT(ingredientsListEditTriggered())); + connect(m_lpIngredientsListEdit, &QAction::triggered, this, &cMainWindow::ingredientsListEditTriggered); + + connect(ui->m_lpIngredientsList, &QTreeView::doubleClicked, this, &cMainWindow::ingredientsListDoubleClicked); + + connect(ui->m_lpMDIArea, &cMdiArea::subWindowActivated, this, &cMainWindow::updateMenus); bool bConnected = false; @@ -137,6 +148,40 @@ void cMainWindow::init() bConnected = true; } loadIngredients(); + + m_lpWindowMenuCloseAct = new QAction(tr("Cl&ose"), this); + m_lpWindowMenuCloseAct->setStatusTip(tr("Close the active window")); + connect(m_lpWindowMenuCloseAct, &QAction::triggered, ui->m_lpMDIArea, &QMdiArea::closeActiveSubWindow); + + m_lpWindowMenuCloseAllAct = new QAction(tr("Close &All"), this); + m_lpWindowMenuCloseAllAct->setStatusTip(tr("Close all the windows")); + connect(m_lpWindowMenuCloseAllAct, &QAction::triggered, ui->m_lpMDIArea, &QMdiArea::closeAllSubWindows); + + m_lpWindowMenuTileAct = new QAction(tr("&Tile"), this); + m_lpWindowMenuTileAct->setStatusTip(tr("Tile the windows")); + connect(m_lpWindowMenuTileAct, &QAction::triggered, ui->m_lpMDIArea, &QMdiArea::tileSubWindows); + + m_lpWindowMenuCascadeAct = new QAction(tr("&Cascade"), this); + m_lpWindowMenuCascadeAct->setStatusTip(tr("Cascade the windows")); + connect(m_lpWindowMenuCascadeAct, &QAction::triggered, ui->m_lpMDIArea, &QMdiArea::cascadeSubWindows); + + m_lpWindowMenuNextAct = new QAction(tr("Ne&xt"), this); + m_lpWindowMenuNextAct->setShortcuts(QKeySequence::NextChild); + m_lpWindowMenuNextAct->setStatusTip(tr("Move the focus to the next window")); + connect(m_lpWindowMenuNextAct, &QAction::triggered, ui->m_lpMDIArea, &QMdiArea::activateNextSubWindow); + + m_lpWindowMenuPreviousAct = new QAction(tr("Pre&vious"), this); + m_lpWindowMenuPreviousAct->setShortcuts(QKeySequence::PreviousChild); + m_lpWindowMenuPreviousAct->setStatusTip(tr("Move the focus to the previous window")); + connect(m_lpWindowMenuPreviousAct, &QAction::triggered, ui->m_lpMDIArea, &QMdiArea::activatePreviousSubWindow); + + m_lpWindowMenuSeparatorAct = new QAction(this); + m_lpWindowMenuSeparatorAct->setSeparator(true); + + connect(ui->m_lpMenu_Window, &QMenu::aboutToShow, this, &cMainWindow::updateWindowMenu); + + updateMenus(); + updateWindowMenu(); } void cMainWindow::initDefaultSettings() @@ -187,7 +232,7 @@ void cMainWindow::loadPlugins(const QString& szPluginDir) QAction* lpAction = new QAction(this); ui->m_lpMenu_Plugins_Import->addAction(lpAction); lpAction->setText(lpPlugin->pluginName()); - connect(lpAction, SIGNAL(triggered()), this, SLOT(pluginImportTriggered())); + connect(lpAction, &QAction::triggered, this, &cMainWindow::pluginImportTriggered); lpPlugin->setAction(lpAction); m_pluginList.append(lpPlugin); } @@ -206,7 +251,7 @@ void cMainWindow::loadPlugins(const QString& szPluginDir) QAction* lpAction = new QAction(this); ui->m_lpMenu_Plugins_Export->addAction(lpAction); lpAction->setText(lpPlugin->pluginName()); - connect(lpAction, SIGNAL(triggered()), this, SLOT(pluginExportTriggered())); + connect(lpAction, &QAction::triggered, this, &cMainWindow::pluginExportTriggered); lpPlugin->setAction(lpAction); m_pluginList.append(lpPlugin); } @@ -225,7 +270,7 @@ void cMainWindow::loadPlugins(const QString& szPluginDir) QAction* lpAction = new QAction(this); ui->m_lpMenu_Plugins_Database->addAction(lpAction); lpAction->setText(lpPlugin->pluginName()); - connect(lpAction, SIGNAL(triggered()), this, SLOT(pluginDBTriggered())); + connect(lpAction, &QAction::triggered, this, &cMainWindow::pluginDBTriggered); lpPlugin->setAction(lpAction); m_pluginList.append(lpPlugin); if(settings.value(QString("plugins/%1/enabled").arg(lpPlugin->pluginName()), QVariant(false)).toBool()) @@ -290,6 +335,7 @@ void cMainWindow::loadIngredients() void cMainWindow::pluginImportTriggered() { +/* QAction* lpAction = qobject_cast(sender()); if(lpAction) { @@ -319,7 +365,7 @@ void cMainWindow::pluginImportTriggered() } } } - +*/ } void cMainWindow::pluginExportTriggered() @@ -444,3 +490,89 @@ void cMainWindow::ingredientsListEditTriggered() lpIngredientWindow->show(); } } + +QMdiSubWindow* cMainWindow::activeMdiChild() const +{ + if (QMdiSubWindow* activeSubWindow = ui->m_lpMDIArea->activeSubWindow()) + return(activeSubWindow); + return(0); +} + +void cMainWindow::ingredientsListDoubleClicked(QModelIndex /*modelIndex*/) +{ + this->ingredientsListEditTriggered(); +} + +void cMainWindow::updateMenus() +{ + QMdiSubWindow* lpActiveChild = activeMdiChild(); + bool hasMdiChild = (lpActiveChild != 0); + +// saveAct->setEnabled(hasMdiChild); +// saveAsAct->setEnabled(hasMdiChild); +//#ifndef QT_NO_CLIPBOARD +// pasteAct->setEnabled(hasMdiChild); +//#endif + m_lpWindowMenuCloseAct->setEnabled(hasMdiChild); + m_lpWindowMenuCloseAllAct->setEnabled(hasMdiChild); + m_lpWindowMenuTileAct->setEnabled(hasMdiChild); + m_lpWindowMenuCascadeAct->setEnabled(hasMdiChild); + m_lpWindowMenuNextAct->setEnabled(hasMdiChild); + m_lpWindowMenuPreviousAct->setEnabled(hasMdiChild); + m_lpWindowMenuSeparatorAct->setVisible(hasMdiChild); + +//#ifndef QT_NO_CLIPBOARD +// bool hasSelection = (activeMdiChild() && +// activeMdiChild()->textCursor().hasSelection()); +// cutAct->setEnabled(hasSelection); +// copyAct->setEnabled(hasSelection); +//#endif +} + + +class ActiveMdiSubWindowFunctor +{ +public: + explicit ActiveMdiSubWindowFunctor(QMdiArea *mdiArea, QMdiSubWindow *activeWindow) : m_mdiArea(mdiArea), m_activeWindow(activeWindow) {} + void operator()() const { m_mdiArea->setActiveSubWindow(m_activeWindow); } + +private: + QMdiArea* m_mdiArea; + QMdiSubWindow* m_activeWindow; +}; + +void cMainWindow::updateWindowMenu() +{ + ui->m_lpMenu_Window->clear(); + + ui->m_lpMenu_Window->addAction(m_lpWindowMenuCloseAct); + ui->m_lpMenu_Window->addAction(m_lpWindowMenuCloseAllAct); + ui->m_lpMenu_Window->addSeparator(); + ui->m_lpMenu_Window->addAction(m_lpWindowMenuTileAct); + ui->m_lpMenu_Window->addAction(m_lpWindowMenuCascadeAct); + ui->m_lpMenu_Window->addSeparator(); + ui->m_lpMenu_Window->addAction(m_lpWindowMenuNextAct); + ui->m_lpMenu_Window->addAction(m_lpWindowMenuPreviousAct); + ui->m_lpMenu_Window->addAction(m_lpWindowMenuSeparatorAct); + + QList windowsList = ui->m_lpMDIArea->subWindowList(); + m_lpWindowMenuSeparatorAct->setVisible(!windowsList.isEmpty()); + + QMdiSubWindow* lpActiveChild = activeMdiChild(); + + for(int i = 0; i < windowsList.size(); i++) + { + QMdiSubWindow* lpMdiSubWindow = windowsList.at(i); + + QString str; + + if(i < 9) + str = tr("&%1 %2").arg(i + 1).arg(lpMdiSubWindow->windowTitle()); + else + str = tr("%1 %2").arg(i + 1).arg(lpMdiSubWindow->windowTitle()); + + QAction* lpAction = ui->m_lpMenu_Window->addAction(str, lpMdiSubWindow, ActiveMdiSubWindowFunctor(ui->m_lpMDIArea, lpMdiSubWindow)); + lpAction->setCheckable(true); + lpAction->setChecked(lpMdiSubWindow == lpActiveChild); + } +} diff --git a/Kooky/cmainwindow.h b/Kooky/cmainwindow.h index 90d35aa..efe1c44 100644 --- a/Kooky/cmainwindow.h +++ b/Kooky/cmainwindow.h @@ -32,6 +32,7 @@ #include #include #include +#include namespace Ui @@ -117,6 +118,9 @@ private slots: * */ void ingredientsListEditTriggered(); + void ingredientsListDoubleClicked(QModelIndex modelIndex); + void updateMenus(); + void updateWindowMenu(); private: Ui::cMainWindow* ui; /**< the main window GUI */ @@ -130,6 +134,15 @@ private: cPlugin* m_lpDB; QString m_szLastImportPlugin; + + QAction* m_lpWindowMenuCloseAct; + QAction* m_lpWindowMenuCloseAllAct; + QAction* m_lpWindowMenuTileAct; + QAction* m_lpWindowMenuCascadeAct; + QAction* m_lpWindowMenuNextAct; + QAction* m_lpWindowMenuPreviousAct; + QAction* m_lpWindowMenuSeparatorAct; + /** * \brief Initialized main windows. * @@ -153,6 +166,7 @@ private: * \return cPlugin Plugin corresponding to the action, NULL if not found. */ cPlugin* plugin(QAction* lpAction); + QMdiSubWindow* activeMdiChild() const; protected: }; diff --git a/Kooky/cmainwindow.ui b/Kooky/cmainwindow.ui index 53a72b6..e8c5b67 100644 --- a/Kooky/cmainwindow.ui +++ b/Kooky/cmainwindow.ui @@ -53,14 +53,14 @@ - - - QFrame::StyledPanel - - - QFrame::Raised - - + + + QFrame::StyledPanel + + + QFrame::Raised + + @@ -105,15 +105,21 @@ - + &Tools + + + &Window + + - + + diff --git a/Kooky/cmdiarea.h b/Kooky/cmdiarea.h index 2af2e98..d9687c5 100644 --- a/Kooky/cmdiarea.h +++ b/Kooky/cmdiarea.h @@ -22,10 +22,12 @@ #include #include +#include class cMdiArea : public QMdiArea { + Q_OBJECT public: cMdiArea(QWidget * parent = 0); private: diff --git a/Kooky/cmessageanimatedialog.cpp b/Kooky/cmessageanimatedialog.cpp index c027f3c..60b8c63 100644 --- a/Kooky/cmessageanimatedialog.cpp +++ b/Kooky/cmessageanimatedialog.cpp @@ -34,7 +34,7 @@ void cMessageAnimateDialog::setMessage(const QString& szMessage) delete m_lpTimer; m_lpTimer = new QTimer(this); - connect(m_lpTimer, SIGNAL(timeout()), this, SLOT(update())); + connect(m_lpTimer, &QTimer::timeout, this, &cMessageAnimateDialog::update); m_lpTimer->start(500); } diff --git a/Kooky/coptions.cpp b/Kooky/coptions.cpp index 533a7b0..59709f7 100644 --- a/Kooky/coptions.cpp +++ b/Kooky/coptions.cpp @@ -48,7 +48,7 @@ void cOptions::init() ui->m_lpSplitter->setStretchFactor(0, 0); ui->m_lpSplitter->setStretchFactor(1, 1); - connect(ui->m_lpOptionsTree->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(onOptionsTreeSelectionChanged(QItemSelection,QItemSelection))); + connect(ui->m_lpOptionsTree->selectionModel(), &QItemSelectionModel::selectionChanged, this, &cOptions::onOptionsTreeSelectionChanged); } void cOptions::onOptionsTreeSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) @@ -87,7 +87,7 @@ void cOptions::onOptionsTreeSelectionChanged(const QItemSelection& selected, con cOptionsPlugins* lpOptionsPlugins = new cOptionsPlugins(this); lpOptionsPlugins->setPlugins(m_pluginList); ui->m_lpOptionsScrollArea->setWidget(lpOptionsPlugins); - connect(lpOptionsPlugins, SIGNAL(somethingChanged()), this, SLOT(somethingChanged())); + connect(lpOptionsPlugins, &cOptionsPlugins::somethingChanged, this, &cOptions::somethingChanged); } else { @@ -104,7 +104,7 @@ void cOptions::somethingChanged() ui->m_lpButtonBox->button(QDialogButtonBox::Apply)->setEnabled(true); } -bool cOptions::saveData(QStandardItem* lpItem) +bool cOptions::saveData(QStandardItem* /*lpItem*/) { return(true); } diff --git a/Kooky/coptionsplugins.cpp b/Kooky/coptionsplugins.cpp index 8df7f7a..9d071cd 100644 --- a/Kooky/coptionsplugins.cpp +++ b/Kooky/coptionsplugins.cpp @@ -28,8 +28,8 @@ void cOptionsPlugins::init() QStringList headerLabels = QStringList() << tr("") << tr("Name") << tr("Version") << tr("Capability") << tr("File"); m_lpPluginsListModel->setHorizontalHeaderLabels(headerLabels); - connect(ui->m_lpPluginsList->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(onOptionsPluginTreeSelectionChanged(QItemSelection,QItemSelection))); - connect(ui->m_lpPluginsList, SIGNAL(doubleClicked(QModelIndex)), SLOT(onOptionsPluginTreeDoubleClicked(QModelIndex))); + connect(ui->m_lpPluginsList->selectionModel(), &QItemSelectionModel::selectionChanged, this, &cOptionsPlugins::onOptionsPluginTreeSelectionChanged); + connect(ui->m_lpPluginsList, &QTreeView::doubleClicked, this, &cOptionsPlugins::onOptionsPluginTreeDoubleClicked); } void cOptionsPlugins::setPlugins(QList &plugins) @@ -45,7 +45,7 @@ void cOptionsPlugins::setPlugins(QList &plugins) QCheckBox* lpCheckBox = new QCheckBox(this); lpCheckBox->setChecked(settings.value(QString("plugins/%1/enabled").arg(plugins.at(z)->pluginName()), QVariant(false)).toBool()); ui->m_lpPluginsList->setIndexWidget(m_lpPluginsListModel->index(index.row(), 0), lpCheckBox); - connect(lpCheckBox, SIGNAL(toggled(bool)), this, SLOT(onOptionsPluginTreePluginToggled(bool))); + connect(lpCheckBox, &QCheckBox::toggled, this, &cOptionsPlugins::onOptionsPluginTreePluginToggled); QStandardItem* lpItemText = new QStandardItem(plugins.at(z)->pluginName()); m_lpPluginsListModel->setItem(index.row(), 1, lpItemText); QStandardItem* lpItemVersion = new QStandardItem(QString("%1").arg(plugins.at(z)->pluginVersion())); diff --git a/dSQLite/csqliteplugin.cpp b/dSQLite/csqliteplugin.cpp index bc8d9ae..aeee51e 100644 --- a/dSQLite/csqliteplugin.cpp +++ b/dSQLite/csqliteplugin.cpp @@ -266,7 +266,8 @@ QString cSQLitePlugin::name(qint32 id) m_szLastError = query.lastError().text(); return(""); } - query.first(); + if(!query.first()) + return(""); return(query.value("name").toString()); } @@ -276,12 +277,13 @@ QString cSQLitePlugin::group(qint32 id) return(""); QSqlQuery query(m_db); - if(!query.exec(QString("SELECT ingredient_group.name FROM ingredient, ingredient_group WHERE ingredient.ingredient_group_id=ingredient_group.id AND ingredient.id=%1").arg(id).arg(id))) + if(!query.exec(QString("SELECT ingredient_group.name FROM ingredient, ingredient_group WHERE ingredient.ingredient_group_id=ingredient_group.id AND ingredient.id=%1").arg(id))) { m_szLastError = query.lastError().text(); return(""); } - query.first(); + if(!query.first()) + return(""); return(query.value("name").toString()); } @@ -296,7 +298,8 @@ qreal cSQLitePlugin::get(qint32 id, qint16 ingredientNumber) m_szLastError = query.lastError().text(); return(-1); } - query.first(); + if(!query.first()) + return(0); return(query.value("value").toReal()); } diff --git a/iBleibFit/cbleibfitplugin.cpp b/iBleibFit/cbleibfitplugin.cpp index 6f152cf..66e59e5 100644 --- a/iBleibFit/cbleibfitplugin.cpp +++ b/iBleibFit/cbleibfitplugin.cpp @@ -98,7 +98,7 @@ QStringList cBleibFitPlugin::search(const QString& szSearch, const QString&) QNetworkReply* reply = networkManager.get(request); QEventLoop loop; - QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); + QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit); loop.exec(); QByteArray szData = reply->readAll(); @@ -177,7 +177,7 @@ bool cBleibFitPlugin::load(qint16 iIndex) QNetworkReply* reply = networkManager.get(request); QEventLoop loop; - QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); + QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit); loop.exec(); QByteArray szData = reply->readAll();