Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ Can't call a global function?
    primarykey
    data
    text
    <p>So I have a function in app.cpp, and it is defined in the hpp file;</p> <pre><code>class App : public QObject { //Some stuff here public: App(); void registerToServer(QString apiURL, QUrl params); </code></pre> <p>I am trying to call the function from another .cpp file. I have done the following in the .hpp file;</p> <pre><code>App m_app; </code></pre> <p>Then my call;</p> <pre><code>m_app.registerToServer(etc etc) </code></pre> <p>However I keep getting an error that App 'does not define a type'</p> <p>Thanks</p> <p>Edit: The App.hpp file;</p> <pre><code>#ifndef APP_HPP #define APP_HPP #include "service/ConfigurationService.hpp" #include "service/PushNotificationService.hpp" #include &lt;bb/cascades/GroupDataModel&gt; #include &lt;bb/system/InvokeManager&gt; #include &lt;bb/system/SystemCredentialsPrompt&gt; #include &lt;QtCore/QtCore&gt; #include &lt;QString&gt; #include &lt;bb/cascades/Application&gt; #include &lt;bb/device/HardwareInfo&gt; #include &lt;bb/cascades/AbstractPane&gt; #include &lt;bps/deviceinfo.h&gt; #include &lt;bps/netstatus.h&gt; #include &lt;bps/locale.h&gt; class PushContentController; class App : public QObject { Q_OBJECT QString getDevicePIN(); // The data model that contains all received pushes Q_PROPERTY(bb::cascades::GroupDataModel* model READ model CONSTANT) Q_PROPERTY(bool modelIsEmpty READ modelIsEmpty NOTIFY modelIsEmptyChanged) // The title and body text for the notification dialog Q_PROPERTY(QString notificationTitle READ notificationTitle NOTIFY notificationChanged) Q_PROPERTY(QString notificationBody READ notificationBody NOTIFY notificationChanged) // The title and body text for the activity dialog Q_PROPERTY(QString activityDialogTitle READ activityDialogTitle NOTIFY activityDialogChanged) Q_PROPERTY(QString activityDialogBody READ activityDialogBody NOTIFY activityDialogChanged) // The controller object for the push content page Q_PROPERTY(PushContentController* currentPushContent READ currentPushContent CONSTANT) // The configuration provider application ID. Q_PROPERTY(QString appId READ appId WRITE setAppId NOTIFY appIdChanged) // The configuration Push Proxy Gateway(PPG) URL. Q_PROPERTY(QString ppgUrl READ ppgUrl WRITE setPpgUrl NOTIFY ppgUrlChanged) // The configuration push initiator URL. Q_PROPERTY(QString pushInitiatorUrl READ pushInitiatorUrl WRITE setPushInitiatorUrl NOTIFY pushInitiatorUrlChanged) // The configuration 'useSdk' value. Q_PROPERTY(bool useSdk READ useSdk WRITE setUseSdk NOTIFY useSdkChanged) // The configuration 'launchApplicationOnPush' value. Q_PROPERTY(bool launchApplicationOnPush READ launchApplicationOnPush WRITE setLaunchApplicationOnPush NOTIFY launchApplicationOnPushChanged) // The configuration 'usingPublicPpg' value. Q_PROPERTY(bool usePublicPpg READ usePublicPpg WRITE setUsePublicPpg NOTIFY usePublicPpgChanged) public: App(); void registerToServer(QString apiURL, QUrl params); QSettings newConfigSettings; /** * Saves the Configuration to the persistent store. */ Q_INVOKABLE void saveConfiguration(); /** * Loads the Configuration from the persistent store. */ Q_INVOKABLE void loadConfiguration(); /** * Returns a value that indicates whether or not the Configuration settings are valid. * * @return true if valid; false otherwise */ Q_INVOKABLE bool validateConfiguration(); /** * Calls the push service create channel */ Q_INVOKABLE void createChannel(); /** * Calls the push service destroy channel */ Q_INVOKABLE void destroyChannel(); Q_INVOKABLE void deletePush(const QVariantMap &amp;item); Q_INVOKABLE void deleteAllPushes(); Q_INVOKABLE void markAllPushesAsRead(); Q_INVOKABLE void changeConnectionText(const QString newText); /** * Marks the passed push as current one and prepares the controller * object of the PushContentPage. */ Q_INVOKABLE void selectPush(const QVariantList &amp;indexPath); Q_INVOKABLE void sendSms(const QString &amp;messageText, const QStringList &amp;phoneNumbers); public Q_SLOTS: void onCreateSessionCompleted(const bb::network::PushStatus &amp;status); void onCreateChannelCompleted(const bb::network::PushStatus &amp;status, const QString &amp;token); void onDestroyChannelCompleted(const bb::network::PushStatus &amp;status); void onRegisterToLaunchCompleted(const bb::network::PushStatus &amp;status); void onUnregisterFromLaunchCompleted(const bb::network::PushStatus &amp;status); void onRegisterPromptFinished(bb::system::SystemUiResult::Type value); void onUnregisterPromptFinished(bb::system::SystemUiResult::Type value); void onPIRegistrationCompleted(int code, const QString &amp;description); void onPIDeregistrationCompleted(int code, const QString &amp;description); void onInvoked(const bb::system::InvokeRequest &amp;request); void onSimChanged(); void onPushTransportReady(bb::network::PushCommand::Type command); void quit(); private Q_SLOTS: void httpFinished(QNetworkReply* reply); Q_SIGNALS: void modelIsEmptyChanged(); void notificationChanged(); void activityDialogChanged(); void appIdChanged(); void ppgUrlChanged(); void pushInitiatorUrlChanged(); void useSdkChanged(); void launchApplicationOnPushChanged(); void usePublicPpgChanged(); void openActivityDialog(); void closeActivityDialog(); private: PushDAO m_pushDAO; // A helper function to initialize the push session void initializePushSession(); bool validateUser(const QString &amp;dialogTitle, const QString &amp;username, const QString &amp;password); void loadUser(); void setPromptDefaultText(bb::system::SystemCredentialsPrompt* prompt,const QString &amp;username, const QString &amp;password); void pushNotificationHandler(bb::network::PushPayload &amp;pushPayload); void showDialog(const QString &amp;title, const QString &amp;message); void openActivityDialog(const QString &amp;title, const QString &amp;message); void onNetworkStatusUpdated ( bool connectionStatus, QString interfaceType ); // The accessor methods of the properties bb::cascades::GroupDataModel* model() const; bool modelIsEmpty() const; QString notificationTitle() const; QString notificationBody() const; QString activityDialogTitle() const; QString activityDialogBody() const; PushContentController* currentPushContent() const; QString appId() const; void setAppId(const QString &amp;appId); QString ppgUrl() const; void setPpgUrl(const QString &amp;ppgUrl); QString pushInitiatorUrl() const; void setPushInitiatorUrl(const QString &amp;pushInitiatorUrl); bool useSdk() const; void setUseSdk(bool value); bool launchApplicationOnPush() const; void setLaunchApplicationOnPush(bool launchAppOnPush); bool usePublicPpg() const; void setUsePublicPpg(bool usingPublicPpg); QString getDeviceIMEI(); // The manager object to react to invocations bb::system::InvokeManager *m_invokeManager; // The credentials dialog to register to the push service bb::system::SystemCredentialsPrompt *m_registerPrompt; // The credentials dialog to unregister from the push service bb::system::SystemCredentialsPrompt *m_unregisterPrompt; // The wrapper classes for loading/storing configuration values ConfigurationService m_configurationService; Configuration m_configuration; // The wrapper class for the current user User m_user; PushNotificationService m_pushNotificationService; bool m_shouldRegisterToLaunch; bool m_shouldUnregisterFromLaunch; // The controller object for the push content page PushContentController* m_pushContentController; // The property values bb::cascades::GroupDataModel *m_model; QString m_notificationTitle; QString m_notificationBody; QString m_activityDialogTitle; QString m_activityDialogBody; QString m_appId; QString m_ppgUrl; QString m_pushInitiatorUrl; QString m_connectionStatus; bool m_useSdk; bool m_launchApplicationOnPush; bool m_usePublicPpg; QString device_pin; QNetworkAccessManager m_accessManager; UserDAO m_userDAO; QNetworkReply *m_reply; ConfigurationDAO m_testConfig; }; #endif </code></pre> <p>RegisterToServer function.</p> <pre><code> void App::registerToServer(QString apiURL, QUrl params) { QUrl serviceUrl = QUrl(apiURL); QByteArray postData; postData = params.encodedQuery(); QNetworkAccessManager *networkManager = new QNetworkAccessManager(this); networkManager-&gt;post(QNetworkRequest(serviceUrl),postData); // Connect to the reply finished signal. connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(httpFinished(QNetworkReply*))); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload