Important: Please read the Qt Code of Conduct -

[SOLVED]Need help with combining GUI

  • Greetings to all Qt'er,

    This is my first post. So please excuses me for me for not knowing the topic rules.

    I just got into Qt recently for doing a project and I am not familiar with the user interface and tools. Would like to get some help here.

    Can someone show me an example of combining two Qt GUI project together?



    #update1: Forgot to mention that I just started learning C++

  • Hi
    Welcome to Qt

    Please explain what you mean by 'Combine Qt Projects'

  • Hi GrahamL,

    I just succeeded adding 2 project together. but I can't take info from other project. Take a look at this.

    double freq = StatusWindow::AngularVelocities.gimbalNS1Vel;

    C:\Users\Zhihao\Documents\SourceTree Repos\qtlearning\NISimpleTest - Zhihao Version\stepperwindow.cpp:122: error: expected primary-expression before '.' token
    double freq = StatusWindow::AngularVelocities.gimbalNS1Vel;

    I am not that experience either. Would be real nice if you can help me out.



  • Lifetime Qt Champion


    In stepperwindow.cpp , did you include the .H file where StatusWindow lives ?

  • @mrjj Yes, I did. When I start typing Qt shows me the available namespace and instants.

  • Lifetime Qt Champion

    @zhihaowu said:

    if you place cursor on AngularVelocities and press F2, it can go to the definition ?

  • Lifetime Qt Champion

    Depending on where the files are located, you might need to add paths to the .PRO file

    INCLUDEPATH += ../../Common/CONET

    HEADERS += AppStyle.h

  • This is a part of the header file:

    class StatusWindow : public QMainWindow {

    explicit StatusWindow(QWidget *parent = 0);
    SolTrack soltrack;
    SolTrack::Position oldPosition;

    typedef struct {
      double hhRefVel, decRefVel;
      double azVel, altRefVel;
      double gimbalNS1Vel,gimbalNS2Vel, gimbalEW1Vel,gimbalEW2Vel;
    } AngularVelocities;

    AngularVelocities angVels;

    Ui::StatusWindow *ui;

    void updateStatusScreen();
    void computeAngularVelocities(SolTrack::Position sunPos, SolTrack::Position oldPos, AngularVelocities* angVels);

    private slots:
    void updateStatusScreenCurrent();
    void on_actionAbout_Qt_triggered();
    void on_actionAbout_SolTraQ_triggered();
    void on_actionClose_triggered();
    void on_actionHelp_triggered();

    I need to get the data from the gimbals

  • Lifetime Qt Champion

    ahh I see
    when you say
    double freq = StatusWindow::AngularVelocities.gimbalNS1Vel;
    you try to access AngularVelocities as it was a static struct.
    But its not - so you need an instance of StatusWindow for it to work.


    StatusWindow *MyInst = new StatusWindow ();
    double freq =MyInst->AngularVelocities.gimbalNS1Vel;
    delete MyInst ;

    So if StatusWindow was the mainwindow in the other project, then you
    might not have an instance in the "this" project and you would need to create one.

    Have you considered to move the data to its own file so its easier to use both places ?

  • @mrjj That is a good, but I had the idea of just taking it from another directory. So whenever i update the other files, I will not have to copy and paste it over here again.

  • Lifetime Qt Champion

    Well if you need both projects still working then
    moving the data our from mainwindow to its own file would make it far easier.
    Copy/pasting code often comes back and bite. :)

  • @mrjj

    C:\Users\Zhihao\Documents\SourceTree Repos\qtlearning\NISimpleTest - Zhihao Version\stepperwindow.cpp:126: error: invalid use of 'StatusWindow::AngularVelocities'
    double freq = MyInst->AngularVelocities.gimbalNS1Vel;

  • Lifetime Qt Champion

    @zhihaowu said:

    Hi that's the type definition.
    sorry my bad
    it should be angVels;

    double freq = MyInst->angVels.gimbalNS1Vel;

  • Lifetime Qt Champion

    one note:

    I suspect you need to call
    void computeAngularVelocities(SolTrack::Position sunPos, SolTrack::Position oldPos, AngularVelocities* angVels);

    for angVels to have anything but zero.

  • @mrjj It is working!!! Super thanks mate.

  • Lifetime Qt Champion



  • I am trying to add new features to a GUI. The files for new features such as camera output, video output etc exists on a different location.

    What would be the best way to do agile Qt development.

    With best regards,


  • Lifetime Qt Champion

    Well agile is not different with Qt.
    Just make sure project is under code revision control and go ahead :)

Log in to reply