Cannot create object of QNetworkAccessManager
-
wrote 9 days ago last edited by
I am using QT 6.9.0 and am on windows with MSVC2022.
I can include QNetworkAccessManager with:
#include <QtNetwork/QNetworkAccessManager>
And I can declare a variable just fine:
QNetworkAccessManager* manager;
However when trying to call in my application constructor:
manager = new QNetworkAccessManager(this);
I get a bunch of linking errors.
Is there any common known issue with QNetworkAccessManager on Windows or do I need to configure something to make this work?
-
I am using QT 6.9.0 and am on windows with MSVC2022.
I can include QNetworkAccessManager with:
#include <QtNetwork/QNetworkAccessManager>
And I can declare a variable just fine:
QNetworkAccessManager* manager;
However when trying to call in my application constructor:
manager = new QNetworkAccessManager(this);
I get a bunch of linking errors.
Is there any common known issue with QNetworkAccessManager on Windows or do I need to configure something to make this work?
@YamiTheWitch said in Cannot create object of QNetworkAccessManager:
I get a bunch of linking errors
You must also link against the network library.
-
I am using QT 6.9.0 and am on windows with MSVC2022.
I can include QNetworkAccessManager with:
#include <QtNetwork/QNetworkAccessManager>
And I can declare a variable just fine:
QNetworkAccessManager* manager;
However when trying to call in my application constructor:
manager = new QNetworkAccessManager(this);
I get a bunch of linking errors.
Is there any common known issue with QNetworkAccessManager on Windows or do I need to configure something to make this work?
@YamiTheWitch Did you modify your pro or CMakeLists.txt file like shown in https://doc.qt.io/qt-6/qnetworkaccessmanager.html ?
Also, then you say you get errors you should also post them, else nobody knows what errors you get. -
@YamiTheWitch Did you modify your pro or CMakeLists.txt file like shown in https://doc.qt.io/qt-6/qnetworkaccessmanager.html ?
Also, then you say you get errors you should also post them, else nobody knows what errors you get.wrote 9 days ago last edited by -
@YamiTheWitch What about my question?
-
@YamiTheWitch What about my question?
wrote 9 days ago last edited by@jsulm Oh, adding the cmake lines worked, thanks! Doesn't Qt automatically change the cmake file? Or is that only on project creation? Also I would have loved to reply quicker but there is a 10 minute cooldown for members that don't have at least 1 reputation point.
-
@jsulm Oh, adding the cmake lines worked, thanks! Doesn't Qt automatically change the cmake file? Or is that only on project creation? Also I would have loved to reply quicker but there is a 10 minute cooldown for members that don't have at least 1 reputation point.
@YamiTheWitch said in Cannot create object of QNetworkAccessManager:
Doesn't Qt automatically change the cmake file?
Qt is a C++ framework.
QtCreator would be responsible for the build tools. But it would have to parse your code to figure out what modules you're using to and them to CMakeLists.txt file then. -
1/7