I am reading the C++ GUI Programming with Qt4 2nd Edition book trying to learn Qt. I am completely new to Qt and C++. I have experience with C#, Java, VB, Python, and PHP, but C++ is just so new right now that I'm having trouble figuring out how stuff works. The worst part is I don't know how to Google something like this. Anyways, to my question...
I'm on Chapter 5, Creating Custom Widgets where you subclass QSpinBox in order to create HexSpinBox. This is the code I am referring to:
#ifndef HEXSPINBOX_H
#define HEXSPINBOX_H
#include <QSpinBox>
{
Q_OBJECT
public:
protected:
int valueFromText
(const QString &text
) const;
QString textFromValue
(int value
) const;
private:
};
#endif
#ifndef HEXSPINBOX_H
#define HEXSPINBOX_H
#include <QSpinBox>
class QRegExpValidator;
class HexSpinBox : public QSpinBox
{
Q_OBJECT
public:
HexSpinBox(QWidget *parent = 0);
protected:
QValidator::State validate(QString &text, int &pos) const;
int valueFromText(const QString &text) const;
QString textFromValue(int value) const;
private:
QRegExpValidator *validator;
};
#endif
To copy to clipboard, switch view to plain text mode
My question is about the line
class QRegExpValidator;
To copy to clipboard, switch view to plain text mode
What does this line do? Why am I not doing something like a
#include <QRegExpValidator>
#include <QRegExpValidator>
To copy to clipboard, switch view to plain text mode
instead? This is probably a trivial thing for someone with more experience, so I'm sorry if this is a stupid question. I'm sure I'll have several more simple questions as I keep reading.
Bookmarks