Winapi application doesnt work help



  • Hi i am trying to do one application with xmpp but i have some questions about this code, doesnt work for me:

    #include <QApplication>
    #include "mainwindow.h"
    #ifndef Q_WS_X11
    #include <QtPlugin>
    #endif

    #ifdef _MSC_VER
    int WINAPI WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow)
    {
    int argc = 0;
    char *argv[1];
    #else
    int main(int argc, char *argv[])
    {
    #endif
    QApplication a(argc, argv);
    MainWindow w;
    return a.exec();
    }

    I am trying to do simple winapi application but not Works. thanks in advance any suggestion is good received



  • This post is deleted!

  • Lifetime Qt Champion

    Hi,

    Why all these ifdefs ? Just create your main method as usual in any Qt application.



  • because i did the client like this way:

    #include <QApplication>
    #include <QTranslator>
    #include "mainwindow.h"
    #ifndef Q_WS_X11
    #include <QtPlugin>
    #endif

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    QString locale = QLocale::system().name();
    QTranslator translator;
    translator.load(QString("cliente_") + locale);
    a.installTranslator(&translator);
    w.show();

    return a.exec();
    

    }

    And in server i use this code:
    #include <QApplication>
    #include "mainwindow.h"
    #ifndef Q_WS_X11
    #include <QtPlugin>
    #endif

    #ifdef _MSC_VER
    int WINAPI WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow)
    {
    int argc = 0;
    char *argv[1];
    #else
    int main(int argc, char *argv[])
    {
    #endif
    QApplication a(argc, argv);
    MainWindow w;
    return a.exec();
    }

    It's only for that. The problem is only in the server.


  • Lifetime Qt Champion

    Why do you do that in your server ?



  • Sorry to ask but why do you use WINAPI at all? what library are you using for xmpp?



  • i am using qxmpp library this: https://github.com/qxmpp-project/qxmpp



  • i solved with #include <Windows.h> this library


  • Lifetime Qt Champion

    You still haven't answered the main question: why are you using WinMain for your server ? That's not needed at all, Qt handles that for you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.