vendredi 22 juin 2018

Heritage between class QLayout and class QMainWindow Qt c++

I have a MainWindow class that inherits from QMainWindow. I have another LayoutWindow class that inherits from QLayout. When I declare an instance of the LayoutWindow class, I have an error: error: invalid new-expression of abstract class type ... I do not understand because QMainWindow inherits from QWidget that inherits from QLayout? Here is my code :

Class MainWindow :

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{//instance class LayoutWindow
layoutwindow=new LayoutWindow();

centralArea = new QWidget;
centralArea->setLayout(layoutwindow);
setCentralWidget(centralArea);
}

Class LayoutWindow.h

class LayoutWindow : public QLayout{

Q_OBJECT

public:
LayoutWindow();
};

class LayoutWindow.cpp

LayoutWindow::LayoutWindow(){

 //here is my code
}

Would anyone have some idea of ​​my problem?

Aucun commentaire:

Enregistrer un commentaire