There is a class that inherits QGroupBox (I don’t know if it’s important), and another class that simply stores data and several functions for them. I need to pass to the first class method an instance of the second.
MattyGroupBox.h
#ifndef MATTYGROUPBOX_H #define MATTYGROUPBOX_H public QGroupBox { public: MattyGroupBox(); //void fillFrame(MattyNote & ThisNote); ~MattyGroupBox(); private: void buildFrame(); QLabel* NoteTitleLabel; QLabel* NoteTypeLabel; QLabel* NoteCrTimeAndDateLabel; QLabel* NoteEventTimeAndDateLabel; QLabel* NoteTextLabel; QSpacerItem* horizontalSpacer_1; QSpacerItem* horizontalSpacer_2; QSpacerItem* verticalSpacer; QPushButton* editNoteButton; QPushButton* deleteNoteButton; QHBoxLayout* horizontalLayout_1; QHBoxLayout* horizontalLayout_2; QVBoxLayout *verticalLayout; QGridLayout *gridLayout; }; #endif // MATTYGROUPBOX_H MattyGroupBox.cpp
#include "stdafx.h" #include "MattyGroupBox.h" #include "MattyNote.h" MattyGroupBox::MattyGroupBox() { buildFrame(); } //void MattyGroupBox::fillFrame(MattyNote & ThisNote) //{ //NoteTitleLabel->setText(ThisNote.getTitle()); //NoteTypeLabel->setText(ThisNote.getType()); //NoteTextLabel->setText(ThisNote.getText()); //} void MattyGroupBox::buildFrame() { // тут очень много того, из-за чего потребовалось наследовать класс // добавление элементов Qt } MattyGroupBox::~MattyGroupBox() { delete NoteTitleLabel; delete NoteTypeLabel; delete NoteCrTimeAndDateLabel; delete NoteEventTimeAndDateLabel; delete NoteTextLabel; delete horizontalSpacer_1; delete horizontalSpacer_2; delete verticalSpacer; delete editNoteButton; delete deleteNoteButton; delete horizontalLayout_1; delete horizontalLayout_2; delete verticalLayout; delete gridLayout; } If you uncomment the method, errors will come out:
Error C2511 'void MattyGroupBox::fillFrame(MattyNote &)': overloaded member function not found in 'MattyGroupBox' Error C2061 syntax error: identifier 'MattyNote' MattyNote.h
#ifndef MATTYNOTE_H #define MATTYNOTE_H #include "MattyTime.h" class MattyNote { public: MattyNote(); ~MattyNote(); void setTitle(const QString & Title); void setType(const QString & TypeName); void setType(int TypeId); void setText(const QString & Text); void setEventTime(const QString & EventTime); // Warning! Input format must be: 00:00 void setEventDate(const QString & EventDate); // Warning! Input format must be: 00.00.0000 QString getTitle(); QString getType(); QString getText(); QString getEventTime(); // Format: 00:00 QString getEventDate(); // Format: 00.00.0000 QString getCrTime(); // Format: 00:00 QString getCrDate(); // Format: 00.00.0000 int getTypeId(); TimeAndDate* getEventTimeAndDate(); // Returns a pointer to TimeAndDate structure containing ints TimeAndDate* getCrTimeAndDate(); // Returns a pointer to the TimeAndDate structure containing ints private: int NoteTypeId; QString NoteTitle; QString NoteType; QString NoteText; QString NoteEventTime; // Format: 00:00 QString NoteEventDate; // Format: 00.00.0000 MattyTime* EventTimeAndDate; // Any unspecified part equals -1 MattyTime* CrTimeAndDate; // Automaticly set in constructor of MattyNote }; #endif // MATTYNOTE_H MattyNote.cpp
#include "stdafx.h" #include "MattyNote.h" #include "Constants.h" #include "DbManager.h" MattyNote::MattyNote() { EventTimeAndDate = new MattyTime(); EventTimeAndDate->setUserTimeAndDateNull(); CrTimeAndDate = new MattyTime(); MattyTime::updateCurrTime(); CrTimeAndDate->UserTimeAndDate = MattyTime::CurrTime; } MattyNote::~MattyNote() { delete EventTimeAndDate; delete CrTimeAndDate; } void MattyNote::setTitle(const QString & Title) { NoteTitle = Title; } void MattyNote::setType(const QString & TypeName) { DbManager* MattyNotesDbManager = new DbManager("MattyNotes.sqlite"); NoteTypeId = MattyNotesDbManager->getTypeId(TypeName); NoteType = TypeName; delete MattyNotesDbManager; } void MattyNote::setType(int TypeId) { DbManager* MattyNotesDbManager = new DbManager("MattyNotes.sqlite"); NoteType = MattyNotesDbManager->getTypeName(TypeId); NoteTypeId = TypeId; delete MattyNotesDbManager; } void MattyNote::setText(const QString & Text) { NoteText = Text; } void MattyNote::setEventTime(const QString & EventTime) { if (EventTime.length() == Constants::TimeQStringLength && EventTime[2] == Constants::TimeSeparator) { NoteEventTime = EventTime; QStringList TimeTemp = EventTime.split(Constants::TimeSeparator); EventTimeAndDate->UserTimeAndDate->hour = TimeTemp[0].toInt(); EventTimeAndDate->UserTimeAndDate->minute = TimeTemp[1].toInt(); EventTimeAndDate->UserTimeAndDate->second = 0; } } void MattyNote::setEventDate(const QString & EventDate) { if (EventDate.length() == Constants::DateQStringLength && EventDate[Constants::PositionOfFirstDateSeparator] == Constants::DateSeparator && EventDate[Constants::PositionOfSecondDateSeparator] == Constants::DateSeparator) { NoteEventDate = EventDate; QStringList DateTemp = EventDate.split(Constants::DateSeparator); EventTimeAndDate->UserTimeAndDate->day = DateTemp[0].toInt(); EventTimeAndDate->UserTimeAndDate->month = DateTemp[1].toInt(); EventTimeAndDate->UserTimeAndDate->year = DateTemp[2].toInt(); EventTimeAndDate->setUserDayOfWeek(); } } QString MattyNote::getTitle() { return NoteTitle; } QString MattyNote::getType() { return NoteType; } QString MattyNote::getText() { return NoteText; } QString MattyNote::getEventTime() { return NoteEventTime; } QString MattyNote::getEventDate() { return NoteEventDate; } QString MattyNote::getCrTime() { return CrTimeAndDate->PrintUserTime(); } QString MattyNote::getCrDate() { return CrTimeAndDate->PrintUserDate(); } int MattyNote::getTypeId() { return NoteTypeId; } TimeAndDate * MattyNote::getEventTimeAndDate() { return EventTimeAndDate->UserTimeAndDate; } TimeAndDate * MattyNote::getCrTimeAndDate() { return CrTimeAndDate->UserTimeAndDate; } stdafx.h does not include headers at all, Constants.h, DbManager.h, MattyTime.h and their cpps also do not send anywhere.
Actually, what could be the matter? In general, in the project there are 10 files of headers and code, if you need something else, I'll post it.