Включение заголовочного файла вызывает множество ошибокC++

Программы на C++. Форум разработчиков
Ответить Пред. темаСлед. тема
Anonymous
 Включение заголовочного файла вызывает множество ошибок

Сообщение Anonymous »

Когда я #include файл, я получаю ошибки, возникающие в любой строке, указывающей на другой класс. Вот такие (на самом деле их 12...):
x:\development\inkpuppet\newdialog.h:20: error: C2143: syntax error : missing ';' before '*'

x:\development\inkpuppet\newdialog.h:20: error: C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Это происходит, когда я пишу InkPuppet *pointerToPuppet;.
Включение, которое я не могу поместить в заголовок, — это inkspot.h в заголовке inkpuppet.h.
Для каждого указателя я получаю две вышеуказанные ошибки x3, затем я получаю ошибки, потому что, очевидно, указатели больше не работают.< /p>
Я не знаю, какие части моего кода будут актуальны.
inkpuppet.h
#ifndef INKPUPPET_H
#define INKPUPPET_H

#include "inkspot.h"
//#include "ui_inkpuppet.h"

#include
#include

namespace Ui {
class InkPuppet;
}

class InkPuppet : public QMainWindow
{
Q_OBJECT

public:
explicit InkPuppet(QWidget *parent = 0);
~InkPuppet();

Ui::InkPuppet *ui;

private slots:
void setMinimum(int value);
void setMaximum(int value);
void actionNew();
void actionAbout();
void setSpacing(int);
void on_colorAButton_clicked();
};

#endif // INKPUPPET_H

inkpuppet.cpp
#include "inkpuppet.h"
#include "ui_inkpuppet.h"
#include "newdialog.h"
#include "aboutdialog.h"
#include "inkspot.h"

#include
#include
#include
#include
#include
#include
#include
#include

InkPuppet::InkPuppet(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::InkPuppet)
{
ui->setupUi(this);
//connect the frame range boxes to the timeslider
connect(ui->lowerFrameBox, SIGNAL(valueChanged(int)), this, SLOT(setMinimum(int)));
connect(ui->upperFrameBox, SIGNAL(valueChanged(int)), this, SLOT(setMaximum(int)));

//connect tool palette items
connect(ui->spacingBox, SIGNAL(valueChanged(int)), this, SLOT(setSpacing(int)));

connect(ui->colorAButton, SIGNAL(clicked()), this, SLOT(on_colorAButton_clicked()));

//connect the menu items
connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(actionNew()));
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(actionAbout()));

}

void InkPuppet::setMinimum(int value)
{
ui->timeSlider->setMinimum(value);
ui->frameNumberBox->setMinimum(value);
}

void InkPuppet::setMaximum(int value)
{
ui->timeSlider->setMaximum(value);
ui->frameNumberBox->setMaximum(value);
}

void InkPuppet::setSpacing(int)
{
InkSpot *spot = new InkSpot(this);
//spot->puppet = this;
spot->spacing = ui->spacingBox->value();
}

//menu items
void InkPuppet::actionNew()
{
NewDialog *nDialog = new NewDialog;
//nDialog->createNew(this);
nDialog->pointerToPuppet = this;
nDialog->setModal(true);

nDialog->show();

}

void InkPuppet::actionAbout()
{
AboutDialog *aDialog = new AboutDialog;
aDialog->setModal(true);
aDialog->show();
}

//tool menu
void InkPuppet::on_colorAButton_clicked()
{
// QColor color = QColorDialog(QColor->setRgb(255, 0, 0));
// //color->setRgb(0, 0, 0);
// qDebug() isValid())
// {

// QString qss = QString("background-color: %1").arg(color->name());
// ui->colorAButton->setStyleSheet(qss);
// }
}

InkPuppet::~InkPuppet()
{
delete ui;
}

inkspot.h
#ifndef INKSPOT_H
#define INKSPOT_H

#include "newdialog.h"
//#include "inkpuppet.h"

#include
#include
#include
#include
#include
#include
#include

namespace Ui {
class InkSpot;
}

class InkSpot : public QWidget
{
Q_OBJECT
public:
explicit InkSpot(QWidget *parent = 0);
void draw(QPainter *painter);
QWidget *widget;
int canvasWidth;
int canvasHeight;
float spacing;
NewDialog *newDialog;
QPixmap pixmap;

signals:
//int sendWidthOfCanvas();
//void sendHeightOfCanvas();

public slots:
//void widthOfCanvas();
//void heightOfCanvas();

protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void paintEvent(QPaintEvent *event);

private:
void drawLineTo(const QPoint &endPoint);
bool drawing;
QPoint lastPoint;
QImage image;
QImage test2;

Ui::InkSpot *ui;

};

#endif // INKSPOT_H

inkspot.cpp
#include "inkspot.h"
#include "inkpuppet.h"
#include "ui_inkpuppet.h"

#include "newdialog.h"
#include "ui_newdialog.h"

#include
#include
#include
#include
#include

InkSpot::InkSpot(QWidget *parent) :
QWidget(parent)
{
widget = this;
drawing = false;
//spacing = puppet->ui->spacingBox->value();
spacing = 1;//puppet->ui->spacingBox->value();
}

void InkSpot::mousePressEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton)
{
lastPoint = event->pos();
drawing = true;
}
}

void InkSpot::mouseMoveEvent(QMouseEvent *event)
{
if((event->buttons() & Qt::LeftButton) && drawing)
{
drawLineTo(event->pos());
}
}

void InkSpot::mouseReleaseEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton && drawing)
{
drawLineTo(event->pos());
drawing = false;
}
}

void InkSpot::drawLineTo(const QPoint &endPoint)
{
QPainter painter(&pixmap);
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::NoBrush);

QFile *stencilInput; // file for input, assumes a SQUARE RAW 8 bit grayscale image, no JPG no GIF, no size/format header, just 8 bit values in the file
char *brushPrototype; // raw brush prototype
uchar *brushData; // raw brush data

stencilInput = new QFile("C:/brush3.raw"); // open raw file
stencilInput->open(QIODevice::ReadOnly);
QDataStream in;
in.setDevice(stencilInput);
int size = stencilInput->size(); // set size to the length of the raw file

brushPrototype = new char[size]; // create the brush prototype array
in.readRawData(brushPrototype, size); // read the file into the prototype
brushData = new uchar[size]; // create the uchar array you need to construct QImage

for (int i = 0; i < size; ++i)
brushData = (uchar)brushPrototype; // copy the char to the uchar array

QImage test(brushData, 128, 128, QImage::Format_Indexed8); // create QImage from the brush data array
// 128x128 was my raw file, for any file size just use the square root of the size variable provided it is SQUARE
QImage test2(128, 128, QImage::Format_ARGB32);

QVector vectorColors(256); // create a color table for the image
for (int c = 0; c < 256; c++)
vectorColors[c] = qRgb(c, c, c);

test.setColorTable(vectorColors); // set the color table to the image

for (int iX = 0; iX < 128; ++iX) // fill all pixels with 255 0 0 (red) with random variations for OIL PAINT effect
// use your color of choice and remove random stuff for solid color
// the fourth parameter of setPixel is the ALPHA, use that to make your brush transparent by multiplying by opacity 0 to 1
{
for (int iY = 0; iY < 128; ++iY)
{
test2.setPixel(iX, iY, qRgba(255, 100, 100, (255-qGray(test.pixel(iX, iY)))*0.5));
}
}
// final convertions of the stencil and color brush
QPixmap testPixmap = QPixmap::fromImage(test2);
QPixmap testPixmap2 = QPixmap::fromImage(test);

painter.setBrush(Qt::NoBrush);
painter.setPen(Qt::NoPen);
// in a paint event you can test out both pixmaps
// QLineF line = QLineF(lastPoint, endPoint);
// float lineLength = line.length();
// qDebug() newDialog = this;
pointerToPuppet->ui->canvas->addWidget(ink->widget);
//QSize size = pointerToPuppet->ui->canvas->sizeHint();
ink->widget->resize(ui->widthBox->value(), ui->heightBox->value());
pointerToPuppet->ui->scrollCanvasItems->resize(ui->widthBox->value(), ui->heightBox->value());
//pointerToPuppet->ui->canvas->setAlignment(ink->widget, Qt::AlignAbsolute);
ink->pixmap = QPixmap(QSize(ui->widthBox->value(), ui->heightBox->value()));
close();
}

NewDialog::~NewDialog()
{
delete ui;
}

main.cpp
#include "inkpuppet.h"
#include "inkspot.h"
#include "newdialog.h"
#include "aboutdialog.h"
#include

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
InkPuppet w;
w.show();

return a.exec();
}


Подробнее здесь: https://stackoverflow.com/questions/185 ... -of-errors
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C++»