E
E
Egorithm2017-01-29 22:44:17
Qt
Egorithm, 2017-01-29 22:44:17

Qt. Why is a derived class created by default?

I just started learning Qt Framework. Created "Application Qt Widgets"
d8242c36afb94d80a92f4ba78f9665a1.png
And by default a derived class from QWidget was added.

#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>

namespace Ui {
    class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

    private:
        Ui::Widget *ui;

    public:
        explicit Widget(QWidget *parent = 0);
        ~Widget();
};

#endif // WIDGET_H

Is it required or what?
I commented out the header file and method definitions, created an object from QWidget, instead of a derived Widget. Everything started exactly the same way.
I'm reading "Qt 5.3. Professional C++ Programming. Max Schlee"
There are few and not very good examples. Can you advise, if there is, something else, plus to this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jacob E, 2017-01-29
@EgoRusMarch

It will work, why not. But when you want to modify it somehow, you can’t do without inheritance.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question