QtDropbox icon indicating copy to clipboard operation
QtDropbox copied to clipboard

QEventLoop: Cannot be used without QApplication

Open iMartinezMateu opened this issue 9 years ago • 4 comments

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.

iMartinezMateu avatar Jun 05 '15 16:06 iMartinezMateu

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?

lycis avatar Jun 08 '15 10:06 lycis

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.

iMartinezMateu avatar Jun 08 '15 10:06 iMartinezMateu

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

lycis avatar Nov 09 '15 17:11 lycis

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 https://github.com/lycis/QtDropbox/issues/45.

vladest avatar Nov 09 '15 17:11 vladest