Good day to all! With Qt newbie, something stupid. So there is a class declaration:

#include <QLabel> #include <QDialog> #include <gst/gst.h> #include "pipeline.h" namespace Ui { class Draw; } class Draw : public QDialog { Q_OBJECT public: int MaxCounter; QLabel *Label; GstBuffer *Buffer; private: Ui::Draw *ui; Pipeline *pPipe; int VidCounter; public: Draw(Pipeline *, QWidget *parent = 0); int DrawBuffer(void); private: }; 

Implementation:

 #include "draw.h" Draw::Draw(Pipeline *p, QWidget *parent) : QDialog(parent), ui(new Ui::Draw) { pPipe = p; VidCounter = 0; QLabel mode; mode.setPixmap(QPixmap(QString::fromUtf8(":/icons/mode1.png"))); mode.setGeometry(QRect(42, 40, 49, 69)); mode.show(); while(1); } 

However, when trying to compile, it produces 2 errors: error: invalid use of incomplete type 'struct Ui :: Draw' and error: forward declaration of 'struct Ui :: Draw'.

How to deal with this mind I will not put it .. If I remove inheritance, then QLabel is not displayed on the screen, only the cursor in the center of the screen is visible.

Thanks for any help and thoughts!

PS Corrected. However, there was another issue with compilation. Definition:

 namespace Ui { class Draw; } class Ui::Draw : public QDialog { Q_OBJECT public: int MaxCounter; QLabel *Label; GstBuffer *Buffer; private: Ui::Draw *ui; Pipeline *pPipe; int VidCounter; public: Draw(Pipeline *, QWidget *parent = 0); int DrawBuffer(void); private: }; 

Implementation:

 Ui::Draw::Draw(Pipeline *p, QWidget *parent) : QDialog(parent), ui(new Ui::Draw) { pPipe = p; VidCounter = 0; QLabel mode; mode.setPixmap(QPixmap(QString::fromUtf8(":/icons/mode1.png"))); mode.setGeometry(QRect(42, 40, 49, 69)); mode.show(); while(1); } 

But now it does not compile with the following errors:

 error: no matching function for call to 'Ui::Draw::Draw()' candidates are: Ui::Draw::Draw(Pipeline*, QWidget*) note: Ui::Draw::Draw(const Ui::Draw&) 

Something I'm in a stupor .. I do not understand what is wrong for him?

  • and where is the implementation int DrawBuffer(void); (by the way, why there, it is possible and without void) - KoVadim
  • I decided that DrawBuffer () does not relate to this problem, so I didn’t bring it up ... As for void, the habit of C is left. - Xuch
  • just an error hints that not all class functions were implemented (or accidentally forgot to implement them). If the samples are shown (full), then most likely the reason can be found. - KoVadim
  • one
    You have two different classes: Ui::Draw and ::Draw . - user194374
  • one
    Add #include "ui_draw.h" in .cpp . This file in the build process creates a utility utility uic from your draw.ui - aleks.andr

2 answers 2

In general, figured out. The problem was that he gave the same name to the form: Draw and his class: also Draw. In the source code I changed the name of the form to WDraw, in draw.h I connected #include "ui_WDraw.h" and it all worked.

Thank you all for the help and tips!

    QLabel not displayed on screen

    and doing the right thing.

    Here you create a QLabel object on the stack, and therefore, when the constructor finishes its work, it collapses:

     Ui::Draw::Draw(Pipeline *p, QWidget *parent) : QDialog(parent), ui(new Ui::Draw) { pPipe = p; VidCounter = 0; QLabel mode; mode.setPixmap(QPixmap(QString::fromUtf8(":/icons/mode1.png"))); mode.setGeometry(QRect(42, 40, 49, 69)); mode.show(); while(1); } 

    It will be correct to write like this:

     QLabel* mode = new QLabel(this); ... mode->show(); 

    And by the way, why do we need the last line of the while(1); constructor while(1); ?