Help to deal with inheritance and virtual functions. There is such a class:
.h -
#ifndef CUSTOMSUBWINDOW_H #define CUSTOMSUBWINDOW_H #include <QMdiSubWindow> class CustomSubWindow : public QMdiSubWindow { public: explicit CustomSubWindow(QWidget *parent = 0); virtual void createUI(); }; #endif // CUSTOMSUBWINDOW_H .cpp -
#include "CustomSubWindow.h" CustomSubWindow::CustomSubWindow(QWidget *parent) :QMdiSubWindow(parent) { createUI(); } void CustomSubWindow::createUI() { } There is a heir class:
.h -
#ifndef CAT_PRODUCTS_H #define CAT_PRODUCTS_H #include <CustomSubWindow.h> class CatProducts : public CustomSubWindow { Q_OBJECT public: explicit CatProducts(QWidget *parent = 0); void createUI(); }; #endif // CAT_PRODUCTS_H .srr-
#include "CatProducts.h" CatProducts::CatProducts(QWidget *parent) : CustomSubWindow(parent) { } void CatProducts::createUI() { setWindowTitle("Справочник товаров!!!"); } Those. in the successor, we override the createUI() method, which is called in the constructor of the base class. As I understand it, you need to use late binding, i.e. declare the method virtual. But it does not work. What am I wrong?