Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. USEUNIT (C++ Builder) Equivalent...
Forum Updated to NodeBB v4.3 + New Features

USEUNIT (C++ Builder) Equivalent...

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    James Sprinks
    wrote on 28 Mar 2018, 10:28 last edited by
    #1

    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

    1 Reply Last reply
    0
    • J Offline
      J Offline
      James Sprinks
      wrote on 28 Mar 2018, 10:50 last edited by
      #2

      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!

      M 1 Reply Last reply 28 Mar 2018, 10:55
      0
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 28 Mar 2018, 10:53 last edited by
        #3

        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();
        }
        
        
        1 Reply Last reply
        3
        • J James Sprinks
          28 Mar 2018, 10:50

          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!

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 28 Mar 2018, 10:55 last edited by mrjj
          #4

          @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
          }

          1 Reply Last reply
          3
          • J Offline
            J Offline
            James Sprinks
            wrote on 28 Mar 2018, 12:08 last edited by
            #5

            Yep I thought as much! Thanks for the help!

            1 Reply Last reply
            1

            1/5

            28 Mar 2018, 10:28

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved