solmaxa 17 / 8 / 2 Регистрация: 06.01.2013 Сообщений: 163 |
||||
1 |
||||
08.01.2013, 21:29. Показов 11520. Ответов 2 Метки нет (Все метки)
В первой строке ошибки нет (vec3d — структура Opencv), во второй редактор выдает:
ошибка: invalid use of incomplete type ‘class QDebug’
0 |
NoMasters Псевдослучайный 1946 / 1145 / 98 Регистрация: 13.09.2011 Сообщений: 3,215 |
||||
08.01.2013, 22:40 |
2 |
|||
А что это вы с ним такое пытаетесь сделать? Подозреваю, что подразумевалось нечто вроде
1 |
solmaxa 17 / 8 / 2 Регистрация: 06.01.2013 Сообщений: 163 |
||||
09.01.2013, 20:45 [ТС] |
3 |
|||
))))
0 |
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Closed
balogic opened this issue
Mar 22, 2017
· 11 comments
Comments
I got this issue while trying to build tensor in my Ubuntu machine
OS — Ubuntu
Version — 16.04
It seems that ConnectionData
doesn’t include <QDebug>
though it has to — this is actually the libqmatrixclient code, used by Tensor and Quaternion. I wonder which version of Qt you have and which compiler you’re building with — I haven’t seen this error message before. Anyway, thanks for reporting.
Looking further into your case, I see that <QDebug>
might actually be not included from the depths of Qt header files in case when QT_NO_DEBUG_STREAM
is defined. But in that case, I’m afraid, you’ll get more unrecoverable errors even if you just throw #include <QDebug>
into connectiondata.cpp
.
@balogic , qmake is a separate tool that has its own versioning. Did you install Qt from PPA or do you use the stock Qt (5.5?) version installed with 16.04?
So far I cannot even reproduce the build problem that you have. It builds fine on my Ubuntu VM.
@KitsuneRal I haven’t installed Qt5 explicitly but I have all the build
tools needed. Doesn’t Ubuntu comes with Qt by default? Does missing
Qt5 is actually the issue?
To be on the safe side, please do the following:
sudo apt-get install git cmake qtdeclarative5-dev qtdeclarative5-qtquick2-plugin qtdeclarative5-controls-plugin
This should install all dependencies you may need.
@KitsuneRal I’ve installed it all. But still the same error persists.
I’m out of ideas. Anyway, since in all fairness we actually use qDebug()
in this file, I’m adding a commit with #include <QDebug>
to libqmatrixclient now. Can you please do the same (add #include <QDebug>
to other #include
s in the file connectiondata.cpp
), to see that this resolves your problem?
Now the error changes to QtCore/QJsonObject
No such file or directory
I just noticed — does it try to compile against Qt 4 instead of Qt 5? Do you actually need Qt 4 on your system?
I just got bitten by this, apparently Ubuntu changed the qmake default from qt5 to qt4 at some point… :/
sudo apt install qt5-default
fixes it
I know there has been tons of questions like that, but unfortunately after hours of googling and browsing through all of them, none of the answers I read helped. Therefore I am making my own version of my question. The error message I get is: «error: invalid use of incomplete type ‘std::iterator_traits::value_type {aka class Cell}’» My code:
cell.h
#ifndef CELL_H
#define CELL_H
#include <QPushButton>
#include <QMouseEvent>
#include <vector>
class Padding;
class Cell : public QPushButton
{
Q_OBJECT
public:
friend class Padding;
Cell(int x, int y, Padding* padding, QWidget* parent = 0) : QPushButton(parent), x(x), y(y),
padding(padding)
{
setFixedSize(20, 20);
}
Cell(const Cell& object) : QPushButton(), x(object.x), y(object.y), padding(object.padding)
{
setFixedSize(20, 20);
}
int getX() { return x; };
int getY() { return y; };
bool hasMine() { return mine; };
void setHasMine(bool mine) { this -> mine = mine; };
bool isFlagged() { return flagged; };
bool didExplode() { return exploded; };
bool getHasBeenClicked() { return hasBeenClicked; };
void clicked();
~Cell() {};
Cell operator=(const Cell& object)
{
if(&object == this)
{
return *this;
}
padding = object.padding;
x = object.x;
y = object.y;
mine = object.mine;
flagged = object.flagged;
exploded = object.exploded;
hasBeenClicked = object.hasBeenClicked;
setFixedSize(20, 20);
return *this;
}
private:
Padding* padding;
int x;
int y;
bool mine = false;
bool flagged = false;
bool exploded = false;
bool hasBeenClicked = false;
void mousePressEvent(QMouseEvent* e);
void rightClicked();
};
#endif // CELL_H
cell.cpp
#include "cell.h"
#include "padding.h"
void Cell::mousePressEvent(QMouseEvent* event)
{
if(event -> button() == Qt::LeftButton)
{
clicked();
}
else if(event -> button() == Qt::RightButton)
{
rightClicked();
}
}
void Cell::clicked()
{
hasBeenClicked = true;
// TODO: Set the button frame to flat. DONE.
setFlat(true);
// TODO: Make the button not click able. DONE.
setEnabled(false);
// TODO: Display appropriate number on the button, or mine and end the game. DONE.
if(mine)
{
// TODO: Send game over signal and end the game.
//setIcon(QIcon("mine_clicked.png"));
setText("/");
exploded = true;
padding -> gameOver();
}
else
{
setText(QString::number(padding -> countMinesAround(this)));
}
if(padding -> countMinesAround(this) == 0)
{
// Trigger chain reaction; uncover many neighboring cells, if they are not mines.
padding -> triggerChainReactionAround(this);
}
}
void Cell::rightClicked()
{
if(text() != "f")
{
setText("f");
(padding -> minesLeft)--;
}
else
{
setText("");
(padding -> minesLeft)++;
}
flagged = !flagged;
}
padding.h
#ifndef PADDING_H
#define PADDING_H
#include <QWidget>
#include <QGridLayout>
#include <vector>
class Cell;
class Padding : public QWidget
{
Q_OBJECT
public:
friend class Cell;
enum class Difficulty
{
Beginner,
Intermediate,
Advanced,
Custom
};
Padding(QWidget* parent = 0);
void newGame();
void gameOver();
void setLevel(Padding::Difficulty difficulty) { this -> difficulty = difficulty; };
void setPaddingHeight(int height) { paddingHeight = height; };
void setPaddingWidth(int width) { paddingWidth = width; };
void setMines(int mines) { this -> mines = mines; };
int getMinesLeft() { return minesLeft; };
~Padding() {};
private:
struct DifficultyLevelsProperties
{
struct BeginnerProperties
{
const int PADDING_HEIGHT = 9;
const int PADDING_WIDTH = 9;
const int MINES = 10;
} Beginner;
struct IntermediateProperties
{
const int PADDING_HEIGHT = 16;
const int PADDING_WIDTH = 16;
const int MINES = 40;
} Intermediate;
struct AdvancedProperties
{
const int PADDING_HEIGHT = 16;
const int PADDING_WIDTH = 40;
const int MINES = 99;
} Advanced;
} LevelProperties;
Difficulty difficulty = Difficulty::Beginner;
int paddingHeight;
int paddingWidth;
int mines;
// Mines that are not flagged.
int minesLeft;
// Time in seconds since the game was started.
int secondsSinceStart;
std::vector<Cell> cells;
QGridLayout* paddingLayout;
const int CELLS_HEIGHT = 20;
const int CELLS_WIDTH = 20;
int countMinesAround(Cell*);
void triggerChainReactionAround(Cell*);
void updateSecondsSinceStart();
};
#endif // PADDING_H
padding.cpp
#include "padding.h"
#include <QGridLayout>
#include <QTimer>
#include <QTime>
#include <QDebug>
#include "cell.h"
Padding::Padding(QWidget* parent) : QWidget(parent)
{
newGame();
paddingLayout = new QGridLayout(this);
paddingLayout -> setSpacing(0);
}
void Padding::newGame()
{
if(difficulty == Padding::Difficulty::Beginner)
{
paddingHeight = LevelProperties.Beginner.PADDING_HEIGHT;
paddingWidth = LevelProperties.Beginner.PADDING_WIDTH;
mines = LevelProperties.Beginner.MINES;
}
else if(difficulty == Padding::Difficulty::Intermediate)
{
paddingHeight = LevelProperties.Intermediate.PADDING_HEIGHT;
paddingWidth = LevelProperties.Intermediate.PADDING_WIDTH;
mines = LevelProperties.Intermediate.MINES;
}
else if(difficulty == Padding::Difficulty::Advanced)
{
paddingHeight = LevelProperties.Advanced.PADDING_HEIGHT;
paddingWidth = LevelProperties.Advanced.PADDING_WIDTH;
mines = LevelProperties.Advanced.MINES;
}
minesLeft = mines;
cells.clear();
for(int i = 0; i < paddingHeight; i++)
{
for(int j = 0; j < paddingWidth; j++)
{
// TODO: Use smart pointers instead of raw pointers.
Cell* cell = new Cell(j + 1, i + 1, this);
cells.push_back(*cell);
delete cell;
}
}
qsrand(QTime::currentTime().msec());
for(int i = 0; i < mines; i++)
{
// TODO: Fix the randomness of the numbers. DONE.
cells[qrand() % (paddingHeight * paddingWidth) + 1].setHasMine(true);
}
for(int i = 0; i < cells.size(); i++)
{
paddingLayout -> addWidget(&cells[i], cells[i].getY(), cells[i].getX());
}
}
void Padding::gameOver()
{
for(int i = 0; i < cells.size(); i++)
{
cells[i].setEnabled(false);
if((cells[i].hasMine()) && (!cells[i].getHasBeenClicked()))
{
cells[i].clicked();
}
}
}
int Padding::countMinesAround(Cell*)
{
int minesCounter = 0;
for(int i = 0; i < cells.size(); i++)
{
qDebug() << QString::number(cells[i].getX());
if(((x - cells[i].getX() == 0) || (x - cells[i].getX() == 1) || (x -
cells[i].getX() == -1)) && ((y - cells[i].getY() == 0) || (y -
cells[i].getY() == 1) || (y - cells[i].getY() == -1)) &&
(cells[i].hasMine()))
{
minesCounter++;
}
}
return minesCounter;
}
void Padding::triggerChainReactionAround(Cell*)
{
for(int i = 0; i < cells.size(); i++)
{
if(((x - cells[i].getX() == 0) || (x - cells[i].getX() == 1) || (x -
cells[i].getX() == -1)) && ((y - cells[i].getY() == 0) || (y -
cells[i].getY() == 1) || (y - cells[i].getY() == -1)) &&
(!cells[i].getHasBeenClicked()))
{
cells[i].clicked();
}
}
}
Sorry for how long the whole thing, but I could not shorten it as I can’t locate what causes the error. Also please ignore any TODO’s or any lines that are commented out and I forgot to delete them. Please help!
solmaxa 17 / 8 / 2 Регистрация: 06.01.2013 Сообщений: 163 |
||||
1 |
||||
08.01.2013, 21:29. Показов 10910. Ответов 2 Метки нет (Все метки)
В первой строке ошибки нет (vec3d — структура Opencv), во второй редактор выдает:
ошибка: invalid use of incomplete type ‘class QDebug’
__________________ 0 |
NoMasters Псевдослучайный 1946 / 1145 / 98 Регистрация: 13.09.2011 Сообщений: 3,215 |
||||
08.01.2013, 22:40 |
2 |
|||
А что это вы с ним такое пытаетесь сделать? Подозреваю, что подразумевалось нечто вроде
1 |
solmaxa 17 / 8 / 2 Регистрация: 06.01.2013 Сообщений: 163 |
||||
09.01.2013, 20:45 [ТС] |
3 |
|||
))))
0 |
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Closed
balogic opened this issue
Mar 22, 2017
· 11 comments
Comments
I got this issue while trying to build tensor in my Ubuntu machine
OS — Ubuntu
Version — 16.04
It seems that ConnectionData
doesn’t include <QDebug>
though it has to — this is actually the libqmatrixclient code, used by Tensor and Quaternion. I wonder which version of Qt you have and which compiler you’re building with — I haven’t seen this error message before. Anyway, thanks for reporting.
Looking further into your case, I see that <QDebug>
might actually be not included from the depths of Qt header files in case when QT_NO_DEBUG_STREAM
is defined. But in that case, I’m afraid, you’ll get more unrecoverable errors even if you just throw #include <QDebug>
into connectiondata.cpp
.
@balogic , qmake is a separate tool that has its own versioning. Did you install Qt from PPA or do you use the stock Qt (5.5?) version installed with 16.04?
So far I cannot even reproduce the build problem that you have. It builds fine on my Ubuntu VM.
@KitsuneRal I haven’t installed Qt5 explicitly but I have all the build
tools needed. Doesn’t Ubuntu comes with Qt by default? Does missing
Qt5 is actually the issue?
To be on the safe side, please do the following:
sudo apt-get install git cmake qtdeclarative5-dev qtdeclarative5-qtquick2-plugin qtdeclarative5-controls-plugin
This should install all dependencies you may need.
@KitsuneRal I’ve installed it all. But still the same error persists.
I’m out of ideas. Anyway, since in all fairness we actually use qDebug()
in this file, I’m adding a commit with #include <QDebug>
to libqmatrixclient now. Can you please do the same (add #include <QDebug>
to other #include
s in the file connectiondata.cpp
), to see that this resolves your problem?
Now the error changes to QtCore/QJsonObject
No such file or directory
I just noticed — does it try to compile against Qt 4 instead of Qt 5? Do you actually need Qt 4 on your system?
I just got bitten by this, apparently Ubuntu changed the qmake default from qt5 to qt4 at some point… :/
sudo apt install qt5-default
fixes it
Почему выпадает ошибка в такой записи:
QList<QString> list;
list << "AAAA" << "BBBB" << "CCCC";
QListIterator<QString> it(list);
while(it.hasNext())
{
QDebug() << "Element: " << it.next();
}
error: invalid use of incomplete type ‘struct QDebug’
forward declaration of ‘struct QDebug’
cy6erGn0m
19.6k1 золотой знак31 серебряный знак37 бронзовых знаков
задан 28 июн 2011 в 19:28
Думаю, вы не подключили QDebug.
#include <QDebug>
ответ дан 28 июн 2011 в 19:30
cy6erGn0mcy6erGn0m
19.6k1 золотой знак31 серебряный знак37 бронзовых знаков
1
Details
-
Type:
Bug
-
Status:
Closed -
Priority:
P0: Blocker -
Resolution:
Done
-
Affects Version/s:
5.11.0 Alpha
-
Environment:
Linux openSUSE_42_3 (gcc-x86_64) — DeveloperBuild, NoPch, AbortTestingOnFirstFailure
Linux openSUSE_42_3 (icc_18-x86_64) — DeveloperBuild, NoPch, DisableTests, SystemSQLite, AbortTestingOnFirstFailure
-
Commits:
a79d9da8e0bbc69053d00dd1ff1dd55c47258291
Description
Gerrit Reviews
No reviews matched the request. Check your Options in the drop-down menu of this sections header.
Activity
Problem:
You are compiling a C/C++ program using GCC. You get an error message similar to this:
error: invalid use of incomplete type ‘class SomeType’
Solution:
There are multiple possible issues, but in general this error means that GCC can’t find the full declaration of the given class or struct.
The most common issue is that you are missing an #include
clause. Find out in which header file the declaration resides, i.e. if the error message mentions class Map
, look for something like
class Map { // ... };
Usually the classes reside in header files that are similar to their name, e.g. MyClass
might reside in a header file that is called MyClass.h
, MyClass.hpp
or MyClass.hxx
, so be sure to look for those files first. Note that you might also be looking for a type from a library. Often the best approach is to google C++ <insert the missing type here>
to find out where it might be located.
Another possible reason is that you have your #include
clause after the line where the error occurs. If this is the case, ensure that all required types are included before they are used.
For other reasons, see StackOverflow, e.g. this post
Автор | Тема: invalid use of incomplete type (решено) (Прочитано 24680 раз) |
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
Заголовочные файлы надо писать так, чтобы порядок их подключения был неважен.
В реализации подключать первым собственный заголовочник — правильная идея; так мы убеждаемся, что в заголовочнике нет недостающих зависимостей.
Совать #include в пространство имён без хорошего обоснования не стоит.
По вашему обтекаемому описанию не видно, как устроены ваши заголовки, именованное пространство имён или нет, закрыты ли все скобки в хедерах, и т.д. Но причина ошибки очевидна: из-за пространств имён компилятор не отождествил классы в первом и втором заголовке; предварительное объявление «class A;» осталось неразрешённым. Поэкспериментировав, я выяснил вот что.
// Не компилируется!
class A;
namespace XXX {
std::shared_ptr<A> a;
class A { public: int x; };
void xxx();
}
void XXX::xxx() {
a->x;
}
// Компилируется!
class A;
namespace XXX {
class A { public: int x; };
std::shared_ptr<A> a;
void xxx();
}
void XXX::xxx() {
a->x;
}
// Тоже компилируется!
namespace XXX {
class A;
}
namespace XXX {
std::shared_ptr<A> a;
class A { public: int x; };
void xxx();
}
void XXX::xxx() {
a->x;
}
В первом случае shared_ptr<::A>
, который, естественно, не определён (есть XXX::A
).
Во втором — определение наперёд ::A вообще ни на что не сдалось; используется shared_ptr<XXX::A>
.
В третьем примере только один тип, XXX::A.
Если первым идёт не использование, а make_shared — выходит другая ошибка, не удаётся получить sizeof недоопределённого типа A.
Bug 666998
— x11-misc/albert-0.14.22 : /…/telemetry.cpp:83:24: error: invalid use of incomplete type class QDebug
Summary:
x11-misc/albert-0.14.22 : /…/telemetry.cpp:83:24: error: invalid use of inc…
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Note |
Calling ‘debug’ with incomplete return type ‘QDebug’
I’m trying to learn how to create GUIs with QT in c++ using this playlist.
I can’t get through the second tutorial, however, as qDebug is not working. I get the error in the title in my code, and the error
error: invalid use of incomplete type 'class QDebug' qDebug() << "MyRect knows that you pressed a key"; ^
When trying to run the code. What is this, and how can I fix this?
Archived post. New comments cannot be posted and votes cannot be cast.