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. Didn't fully understood ui file handling - and now stuck
Forum Updated to NodeBB v4.3 + New Features

Didn't fully understood ui file handling - and now stuck

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 168 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.
  • L Offline
    L Offline
    LS-KS
    wrote on last edited by
    #1

    Hey folks,
    Last year I build a bigger PySide6 project together with QtQuick QML which is just finished. Now I want to proceed with Qt together with C++.
    For me it's embarrassing: I'm stuck and I don't find the solution.

    I wrote a small program which reads a specific formatted textfile (some crap format someone thought it would be a good idea 20 years ago) which represents a time series.
    In my main window I plot the data, correct some stuff and perform some signal processing. That all works fine.

    But I want to do more: Some trajectories, system identification, create takagi sugeno controllers... and other fancy engineering stuff. But I'm not able to create a second Window.

    I started with the basic empty Qt Project with main main window.h / .cpp /.h .
    From my Menubar i want to use an Action trigger to create an object of the second window. Here is the relevant code:

    //parts from mainwindow.cpp:

    void MainWindow::on_actionTrajektorie_triggered()
    {
        trajectory* traj = new trajectory;
        traj -> show();
    }
    

    // trajectory.h

    #ifndef TRAJECTORY_H
    #define TRAJECTORY_H
    
    #include <QtCharts/QChartView>
    #include <QtCharts/QLineSeries>
    #include <QtCharts/QBarSeries>
    #include <QMainWindow>
    #include <QWidget>
    #include <QColor>
    
    
    QT_BEGIN_NAMESPACE
    namespace Ui { class trajectory; }
    QT_END_NAMESPACE
    
    class trajectory : public QMainWindow
    {
        Q_OBJECT
    public:
        explicit trajectory(QWidget *parent = nullptr);
        ~trajectory();
    
    private:
        Ui::trajectory *ui;
    };
    #endif // TRAJECTORY_H
    
    

    //trajectory.cpp

    #include "trajectory.h"
    #include "ui_trajectory.h"
    #include <QtWidgets/QApplication>
    #include <QtWidgets/QMainWindow>
    #include <QDebug>
    
    trajectory::trajectory(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::trajectory)
    {
        ui->setupUi(this);
    }
    
    trajectory::~trajectory(){
        delete ui;
    }
    

    I post also my .pro file:

    QT       += core gui
    QT += charts
    
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    CONFIG += c++17
    
    # You can make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
        main.cpp \
        mainwindow.cpp \
        trajectory.cpp
    
    HEADERS += \
        mainwindow.h \
        trajectory.h
        complex.h
    FORMS += \
        mainwindow.ui \
        trajectory.ui
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    DISTFILES += \
        data/uf13.txt
    

    I tried to compile several times, cleaned and recreated the project but this doesn't help. I also looked into samples of Qt but don't find the issue.
    I get the following errors:

    <html><body><code style="white-space:pre;font-family:Monaco"><a href="olpfile:///Users/lennartschink/Documents/GitHub/GraphApp/graph_app/trajectory.cpp::9::-1">../graph_app/trajectory.cpp</a>:9:14: error: allocation of incomplete type 'Ui::trajectory'
        , ui(new Ui::trajectory)
                 ^~~~~~~~~~~~~~
    ///Users/..projectpath.../trajectory.h::13::-1">../graph_app/trajectory.h13:22: 
    note: forward declaration of 'Ui::trajectory'
    namespace Ui { class trajectory; }
    

    and

    Users/..projectpath.../trajectory.cpp::11::-1"
    >../graph_app/trajectory.cpp</a>:11:7: error: member access into incomplete type 'Ui::trajectory'
        ui->setupUi(this);
    
    //Users/..projectpath.../trajectory.h::13::-1"
    >../graph_app/trajectory.h</a>:13:22:
    note: forward declaration of 'Ui::trajectory'
    namespace Ui { class trajectory; }
    

    as well as Error 1 in trajectory.o

    Can anybody help?
    Thank you very much!

    1 Reply Last reply
    0
    • L LS-KS has marked this topic as solved on
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You mark the topic has solved without additional information. Is that really the case ? If so, what did fix your issue ? That might help other people.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

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