0xAX
0xAX

Reputation: 21817

Qt widget based on QWidget

I try to create my own widget based in QWidget. In constructor of the class i have:

Square(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);

Square::Square(QWidget *parent = 0, const char *name = 0, WFlags fl)
        : QWidget(parent, name, f)
{
        if (!name)
                setName("Game");
        reset();
        underMouse=false;
}

But i see error: ‘WFlags’ has not been declared

Now i remade my code:

class Square : public QWidget
{
    Q_OBJECT

    public:
        Square(QWidget *parent = 0);
};

and in square.cpp:

Square::Square(QWidget *parent)
        : QWidget(parent)
{
}

But i see error:

Thank you.

Upvotes: 4

Views: 3857

Answers (1)

Steve S
Steve S

Reputation: 5476

If you're using Qt4, the compiler is absolutely right. WFlags has not been declared. It's Qt::WindowFlags. Also, you don't need name -- that's a Qt3 thing.

See http://doc.qt.io/archives/4.6/qwidget.html#QWidget

By the way, I never bother to allow passing WindowFlags through my constructors. If you look at the standard Qt widgets, they don't either (e.g. http://doc.qt.io/archives/4.6/qpushbutton.html#QPushButton).

Upvotes: 9

Related Questions