F
F
FireShip2016-11-14 21:51:16
C++ / C#
FireShip, 2016-11-14 21:51:16

How to include the header file correctly?

Hello! I have a problem that I can't solve all day.
I immediately apologize for the poor code, it will get better.
So, to the point, there is a UserInterface class used to work with the interface. The interface itself is made in Qt Designer and generated using the uic utility.
In qt designer, a promote was made for the widget.
Here is the header file of the widget:

//mainwidget.h
#include <QtWidgets>
#include <QtCore>
#include <QtGui>
#include <iostream>
#include "UserInterface.h"

class MainWidget : public QWidget {
    Q_OBJECT;
public:
    MainWidget(QWidget *parent = 0);
};

So far, it is the same as a normal QWidget.
Actually, the header file "UserInterface.h" is added to this file.
Here is the code for this header:
// UserInterface.h
#include <QtCore>
#include <QtWidgets>
#include <QtGui/QtGui>
#include <vector>
#include "gui.h"
#include <unistd.h>
#include "mainwidget.h"

using namespace std;

class UserInterface  {
    QMainWindow *mainWindow;

    public:
        UserInterface(vector<string> list);
        void start();
        void updateList(vector<string> list);
        void flushFileList();

        vector<string> list;
        Ui_MainWindow *gui;
};

it directly includes "gui.h", which is generated by uic.
So. when the header file UserInterface.h is included in mainwidget.h, nothing works. Specifically, in the IDE, the line is highlighted in red.
Ui_MainWindow *gui;
I tried to look for something similar on stackoverflow, and, in general, I found it, but I could not attach it to my situation.
Most likely described chaotically, ask for answers in the comments, thanks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2016-11-14
@GavriKos

Well, the very first thing is #pragma once or analogues so that there are no several declarations.
Second - Ui_MainWindow is declared somewhere, remember?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question