I have a problem again and I would be greteful to everybody who could help me.
I have a fucntion in a class that I want to use in another without having to rewrite it again. Th eidea is to open a text document from and to work with it in different windows.
May I explain a bit?
1- In First class.cpp (line 13), I am geting the document I want to work with.
2- In second class.cpp (line 10), I retrieve the resulat of the operation and save in list.
My code is just not compiling, and I am suspecting the argument in second class.cpp (line 10) to be wrong, but I have reach my limit at this point.
Any help would be welcome.
Many thanks in advance!
Here is my code:
First class.h
#ifndef DEF_HERITAGE
#define DEF_HERITAGE
#include <QtGui>
{
Q_OBJECT
public:
explicit Heritage
(QWidget *parent
= 0);
virtual ~Heritage();
public slots:
private:
};
#ifndef DEF_HERITAGE
#define DEF_HERITAGE
#include <QtGui>
class Heritage: public QMainWindow
{
Q_OBJECT
public:
explicit Heritage(QWidget *parent = 0);
virtual ~Heritage();
public slots:
void operation1(QTextDocument &doc);
private:
QLineEdit *m_openFile;
};
To copy to clipboard, switch view to plain text mode
First class.cpp
#include "Heritage.h"
#include "ChildWindow.h"
Heritage
::Heritage(QWidget *parent
){
setWindowTitle("Heritage");
setCentralWidget(centralWidget);
}
{
QFile file1
(m_openFile
->text
());
....
}
#include "Heritage.h"
#include "ChildWindow.h"
Heritage::Heritage(QWidget *parent)
{
m_openFile = new QLineEdit;
setWindowTitle("Heritage");
setCentralWidget(centralWidget);
}
void Heritage::operation1(QTextDocument &doc)
{
QFile file1(m_openFile->text());
....
}
To copy to clipboard, switch view to plain text mode
Second class.h
#ifndef DEF_CHILDWINDOW
#define DEF_CHILDWINDOW
#include<QtGui>
#include"Heritage"
{
Q_OBJECT
public:
explicit ChildWindow
(QWidget *parent
= 0);
virtual ~ChildWindow();
public slots:
private:
};
#endif // CHILDWINDOW_H
#ifndef DEF_CHILDWINDOW
#define DEF_CHILDWINDOW
#include<QtGui>
#include"Heritage"
class ChildWindow: public QWidget
{
Q_OBJECT
public:
explicit ChildWindow(QWidget *parent = 0);
virtual ~ChildWindow();
public slots:
void operation2(Heritage &aFile, QStringList &list);
private:
};
#endif // CHILDWINDOW_H
To copy to clipboard, switch view to plain text mode
Second class.cpp
#include "ChildWindow.h"
#include "Heritage.h"
ChildWindow
::ChildWindow(QWidget *parent
) {
}
void ChildWindow
::operation2(Heritage
&aFile,
QStringList &list
) {
list = aFile.operation1(m_openFile->document());
}
ChildWindow::~ChildWindow()
{
;
}
#include "ChildWindow.h"
#include "Heritage.h"
ChildWindow::ChildWindow(QWidget *parent)
: QWidget(parent)
{
}
void ChildWindow::operation2(Heritage &aFile, QStringList &list)
{
list = aFile.operation1(m_openFile->document());
}
ChildWindow::~ChildWindow()
{
;
}
To copy to clipboard, switch view to plain text mode
Bookmarks