Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QEventLoop: Cannot be used without QApplication #45

Open
iMartinezMateu opened this issue Jun 5, 2015 · 4 comments
Open

QEventLoop: Cannot be used without QApplication #45

iMartinezMateu opened this issue Jun 5, 2015 · 4 comments

Comments

@iMartinezMateu
Copy link

Hi,

First I want to show my code:

QDropbox* api;
api= new QDropbox("****","****",QDropbox::Plaintext,"api.dropbox.com");
api->requestToken();
connect(api,SIGNAL(requestTokenFinished(QString,QString)),this,SLOT(requestToken()));

connect(api,SIGNAL(tokenExpired()),this,SLOT(showAuthError()));

The problem I am getting is that when api->requestToken() is being executed, the following error is shown on console "QEventLoop: Cannot be used without QApplication" so neither the requestToken() or showAuthError() is executed. Basically, I want to access and login with a Dropbox account whose credentials was previously inserted in a QDialog. The QApplication is defined in main.c...

I have no idea what is happening here as I am only following the Doxygen documentation.

Thanks.

@lycis
Copy link
Owner

lycis commented Jun 8, 2015

QtDropbox is supposed to be used within a Qt application context only. This thereby requires you to start a QApplication in your code so that a EventLoop and signal/slot handling are available to you.

Did you start the application or only define it?

@iMartinezMateu
Copy link
Author

My main.cpp

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Writer w;
    QTranslator *qtTranslator = new QTranslator();
    QTranslator *translator = new QTranslator();
    if (qtTranslator->load("qt_" + QLocale::system().name(), ":/languages")) {
        a.installTranslator(translator);
    }



    w.show();
    return a.exec();
}

Then, it executes the Main Window. The QDropbox lib is supposed to be included and executed in a dialog inside this main window.

In the Dialog.cpp there is no redefinition of QApplication and there aren't any reference to it.

@lycis
Copy link
Owner

lycis commented Nov 9, 2015

I can unfortunately not reproduce this issue. Can you provide a minimal example code that shows the erroneous behaviour?

@vladest
Copy link

vladest commented Nov 9, 2015

You have to execute app.exec() to start event loop
On Jun 5, 2015 6:03 PM, "Iván Martínez Mateu" [email protected]
wrote:

Hi,

First I want to show my code:

QDropbox* api;
api= new QDropbox("_","_",QDropbox::Plaintext,"api.dropbox.com");
api->requestToken();
connect(api,SIGNAL(requestTokenFinished(QString,QString)),this,SLOT(requestToken()));

connect(api,SIGNAL(tokenExpired()),this,SLOT(showAuthError()));

The problem I am getting is that when api->requestToken() is being
executed, the following error is shown on console "QEventLoop: Cannot be
used without QApplication" so neither the requestToken() or showAuthError()
is executed. Basically, I want to access and login with a Dropbox account
whose credentials was previously inserted in a QDialog. The QApplication is
defined in main.c...

I have no idea what is happening here as I am only following the Doxygen
documentation.

Thanks.


Reply to this email directly or view it on GitHub
#45.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants