el33t
4th August 2010, 20:00
Hi people,
I'm a beginner in C++ and recently started learning Qt. I was just going through the QT 'Find Files' example when I got this doubt. It is regarding some elements of the 'window.h' header file which is part of the 'Find Files' example.
First let me post the source of the window.h file. Then I'll ask my doubt.
window.h
#ifndef WINDOW_H
#define WINDOW_H
#include <QDialog>
class QComboBox;
class QDir;
class QLabel;
class QPushButton;
class QTableWidget;
class Window : public QDialog
{
Q_OBJECT
public:
Window(QWidget *parent = 0);
private slots:
void browse();
void find();
private:
QStringList findFiles(const QDir &directory, const QStringList &files,
const QString &text);
void showFiles(const QDir &directory, const QStringList &files);
QPushButton *createButton(const QString &text, const char *member);
QComboBox *createComboBox(const QString &text = QString());
void createFilesTable();
QComboBox *fileComboBox;
QComboBox *textComboBox;
QComboBox *directoryComboBox;
QLabel *fileLabel;
QLabel *textLabel;
QLabel *directoryLabel;
QLabel *filesFoundLabel;
QPushButton *browseButton;
QPushButton *findButton;
QTableWidget *filesTable;
};
#endif
Doubt Questions:
As you can see above, all the classes of objects that have been used in the header file have been forward declared (like QLabel, QPushbutton, QDir etc. etc.). But in line no. 24, an object of class QStringlist has been declared without any forward declaration of the class QStringlist. A similar case can be found in line no. 17 where the function takes a argument of the type QWidget.
Can anyone explain why these two classes were not forward declared?
Regards,
I'm a beginner in C++ and recently started learning Qt. I was just going through the QT 'Find Files' example when I got this doubt. It is regarding some elements of the 'window.h' header file which is part of the 'Find Files' example.
First let me post the source of the window.h file. Then I'll ask my doubt.
window.h
#ifndef WINDOW_H
#define WINDOW_H
#include <QDialog>
class QComboBox;
class QDir;
class QLabel;
class QPushButton;
class QTableWidget;
class Window : public QDialog
{
Q_OBJECT
public:
Window(QWidget *parent = 0);
private slots:
void browse();
void find();
private:
QStringList findFiles(const QDir &directory, const QStringList &files,
const QString &text);
void showFiles(const QDir &directory, const QStringList &files);
QPushButton *createButton(const QString &text, const char *member);
QComboBox *createComboBox(const QString &text = QString());
void createFilesTable();
QComboBox *fileComboBox;
QComboBox *textComboBox;
QComboBox *directoryComboBox;
QLabel *fileLabel;
QLabel *textLabel;
QLabel *directoryLabel;
QLabel *filesFoundLabel;
QPushButton *browseButton;
QPushButton *findButton;
QTableWidget *filesTable;
};
#endif
Doubt Questions:
As you can see above, all the classes of objects that have been used in the header file have been forward declared (like QLabel, QPushbutton, QDir etc. etc.). But in line no. 24, an object of class QStringlist has been declared without any forward declaration of the class QStringlist. A similar case can be found in line no. 17 where the function takes a argument of the type QWidget.
Can anyone explain why these two classes were not forward declared?
Regards,