Important: Please read the Qt Code of Conduct -

Retriving "About Qt" text sample code - REPOST

  • Here is a basic top down description:

    starting at "MDI" example
    QMenu -> add main menu item into "menu bar"
    use QAction to implement "pull-down" menu
    use addAction - one of many overloads - to show local info "about xx"
    QAction *run_test = testMenu->addAction
    (tr("&Run test submenu - local about "), this, &MainWindow::about);
    run locally defined function TOK

      use  addAction - one  many overloads - to show remote "About Qt" info "
            the access to "About Qt"  application is gained by  specifying "qApp"      pointer using #define  

    #define qApp (static_cast<QApplication *>(QApplication::instance()))
    and implementing another "addAction"

    aboutQtAct =
    helpMenu->addAction(tr("About &Qt "),
    qApp , &QApplication::aboutQt);

    Here is my specific problem I cannot resolve:

    1. The "MDI" example application is my main project in SUBDIRS scheme.
    2. The 'btscanner" example application is one of the subprojects.
    3. They both build / run as independent projects.
    4. The main "MDI" projects builds / runs as the SUBDIRS" scheme.
    5. "MDI" project has access / runs "About Qt" project.

    HOW to I instruct "MDI" to access/ run "btscanner" project - using QMenu (QAction) ?
    Since it works with "About Qt" it should work with other QApplication, but I have not found the way to refer from "MDI" to "btscanner" .


  • Lifetime Qt Champion


    You are mixing two very different things.

    aboutQt is a slot of the QApplication class.

    btscanner and "MDI" are two different executables. You can't connect them like you connect a signal to a slot.

    If you would like to execute btscanner from "MDI", you should consider using the QProcess class.

  • @AnneRanch
    As @SGaist says, if you want to run your btscanner as a separate program/process you can do so via QProcess.

    Or, refactor your btscanner so that it exposes its functionality through some QWodget-derived class, without a main program. Then you can "load" it into an MDI subwindow.

  • Thanks, what you are all indirectly saying - there is no particular advantage to use SUBDIRS to manage programs. Again SUBDIRS is OK to manage program ( singular) and its dependent libraries. Library as in pre-compiled code .

    Which again is nothing special - "plain" C/C++ (GCC) also manages project / libraries relations .
    Adding another layer - such qMake(s) with additional options ....

    I have used plain C/C++ IDE to add "process" , the main reason I switched to to Qt was GUI and "events" . I'll give QProcess a go.

  • @AnneRanch If you want to invoke the already created executable then use QProcess as suggested by others.
    If you want to have greater control of "btscanner" application and it's instance creation in mdi, then modify the btscanner project as library project and include it as library in mdi project.

  • @AnneRanch
    If you run it as a sub-process, be aware that there will probably be nothing to put/show from your btscanner in an MDI subwindow. Unless it writes some text to stdout, which you would like to capture and display as text in a window.

  • Lifetime Qt Champion

    Again: you are mixing different concepts.

    The SUBDIRS project template is a project management tool. You can build several libraries and executables through it.

    Then, how you handle these multiple executables in the end is a different problem unrelated to the project management part.

Log in to reply