USEUNIT (C++ Builder) Equivalent...



  • Hi All.

    I am trying to appropriate some code written in C++ builder.

    within the main.cpp code it has a USEUNIT command, followed by a class, i.e.

    USEUNIT("dsnotifydlg.cpp");
    
    //____________________________________________________
    
    WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
        try
        {
            Application->Initialize();
            Application->CreateForm(__classid(TForm1), &Form1);
            Application->Run();
        }
        catch (exception &exception)
        {
            Application->ShowException(&exception);
        }
        return 0;
    

    Could anyone tell me the equivalent to USEINIT in QT?

    Thanks

    J



  • I should add this code is from 15 years ago. I have seen comments suggesting it has been replaced with #include so I will try that and report back!


  • Qt Champions 2017

    Hi
    You dont need it in Qt.
    Also there is no concept of auto created forms so a plain main looks like

    #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w; // same as CreateForm (ish)
        w.show();
    
        return a.exec(); // same as  Application->Run();
    }
    
    

  • Qt Champions 2017

    @James-Sprinks

    Yes, you can say useunit is now just plain .h includes.

    Also notice that Widgets/controls can be local variables so this is perfectly valid.
    (unlike builder where you MUST new them)

    void showdialog() {
    MyDialog dia;
    dia.exec(); // blocking so safe to use non pointers
    }



  • Yep I thought as much! Thanks for the help!


Log in to reply
 

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