QT project in Visual studio

  • Hello all,

    I'm using QT plug-in with Visual studio to create a front end GUI for my C++ based application. I have integrated my dlls and external library files. Created a simple login form in QT designer and coded it to display the login parameters when the pushbutton is clicked (for testing purpose). The solution is build successfully with out any errors. However, the GUI doesn't appear while running. There is no error or warning but the GUI form is not visible.

    It works when I remove my external libraries. But that doesn't help. Any suggestions or comments on why this happens? And how do I debug/ fix it?

  • Moderators

    @prajesw2 We're definitely going to need some more information to help on this.

    If I understand correctly you have a preexisting visual c++ project that you want to add a Qt GUI to? I don't really understand this though. Is it a console application that you want to add a gui to? Is it a set of libraries you want to call with a Qt interface? I'm just not understanding at all.

    Can I see your code to invoke the GUI? How are you building?

  • @ambershark : Yes I have a preexisting visual C++ project. I want to add QT GUI to accept input from users.

    It is a console application which completely works fine in visual studio. But I included the necessary header files and imported the library files and dlls into my QT project in Visual studio.

    My main.cpp:

    #include "biogearsqt.h"
    #include <QtWidgets/QApplication>
    #include <QMessageBox>

    int main(int argc, char *argv[])
    QApplication a(argc, argv);
    biogearsQT w;
    return a.exec();
    QMessageBox msg;
    msg.setText("main func is running");


    #include "biogearsqt.h"
    #include <QLineEdit>
    #include <QMessageBox>

    #include "BioGearsEngineHowTo.h"
    #include "engine/PhysiologyEngineTrack.h"
    #include "scenario/requests/SEDataRequest.h"
    #include "properties/SEScalarTime.h"
    #include "patient/SEPatient.h"
    #include "patient/assessments/SEPulmonaryFunctionTest.h"
    #include "compartment/SECompartmentManager.h"
    #include "compartment/fluid/SEGasCompartment.h"
    #include "compartment/fluid/SELiquidCompartment.h"
    #include "compartment/SECompartmentManager.h"
    #include "system/physiology/SEBloodChemistrySystem.h"
    #include "system/physiology/SECardiovascularSystem.h"
    #include "system/physiology/SEEnergySystem.h"
    #include "system/physiology/SERespiratorySystem.h"
    #include "substance/SESubstanceManager.h"
    #include "substance/SESubstance.h"
    #include "engine/PhysiologyEngineTrack.h"
    #include "utils/SEEventHandler.h"
    #include "properties/SEScalarFraction.h"
    #include "properties/SEScalarFrequency.h"
    #include "properties/SEScalarMassPerVolume.h"
    #include "properties/SEScalarPressure.h"
    #include "properties/SEScalarTemperature.h"
    #include "properties/SEScalarTime.h"
    #include "properties/SEScalarVolume.h"
    #include "properties/SEScalarVolumePerTime.h"
    #include "properties/SEFunctionVolumeVsTime.h"
    #include "properties/SEScalarMass.h"
    #include "properties/SEScalarLength.h"

    biogearsQT::biogearsQT(QWidget *parent)
    : QMainWindow(parent)



    void biogearsQT::on_pushButton_clicked()

    QLineEdit *name = ui.lineEdit_name;
    QLineEdit *age = ui.lineEdit_age;
    QString t_name;
    QString t_age;
    t_name = name->text();
    t_age = age->text();
    int a = t_age.split("")[0].toInt();

    // creates object for class physiology engine
    std::unique_ptr<PhysiologyEngine> bg = CreateBioGearsEngine("Engine.log");
    bg->GetLogger()->Info("Engine initialized");


    // function call


    Once I include "std::unique_ptr<PhysiologyEngine> bg = CreateBioGearsEngine("Engine.log");
    bg->GetLogger()->Info("Engine initialized");
    // function call
    HowToEngineUse(); " these lines in my function, the GUI does not show up. Please let me know if you further information. Thanks!!

    attached a screenshot of the ui form that should show up..


  • Moderators

    @prajesw2 That's interesting... That shouldn't affect the GUI at all. What happens when you include those lines? The GUI just doesn't show up but does the application exit?

    I'm wondering if you're not getting stuck in the create of the biogears engine and therefore Qt can't start it's event loop in the main app.exec(). That would make the gui not show up.

    Does your bg->GetLogger()->Info(...) line work?

    And also what does HowToEngineUse() do?

    You didn't include the screenshot but it's not necessary anyway. ;)

  • Yes totally.. I don't understand why the GUI doesn't appear. There are no build errors or warnings. The project is compiled successfully. I can see the process( .exe) is running in task manager. There is no error. Nothing happens in the window till I stop the debugger.

    bg->GetLogger()->Info(...) line works. it actually updates log. I have this line commented for now.
    HowToEngineUse() is a function that has series of instructions to advance time and stuff like that.

    "I'm wondering if you're not getting stuck in the create of the biogears engine and therefore Qt can't start it's event loop in the main app.exec()." - Do you have any suggestions for debugging?

Log in to reply

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