create object for class inheriting QLayout

408 Views Asked by At

I have a screen class as

   class Screen : public QLayout 
   {
   public:
       Screen();
       ~Screen();
       void paintEvent(QPaintEvent *e);
   };

When I am creating the object I got an error that can not create an object for pure abstract class. Since QLayoput is pure abstract , How can I create an object for a class which is inherits the QLayout ?

definitions:

Screen::Screen( )
{

}

Screen::~Screen()
{
    delete this ;
    //Screen(new QSize (100,100));
}


void Screen::paintEvent(QPaintEvent *e)
{


}
1

There are 1 best solutions below

0
On BEST ANSWER

QLayout is pure abstract, meaning it has virtual members without a definition. To subclass it, you need to provide definitions for all such methods in your class. Specifically, Qt Docs state that

To make your own layout manager, implement the functions addItem(), sizeHint(), setGeometry(), itemAt() and takeAt().

For more, see there (there are additional optional advices for further functions which should be implemented): http://qt-project.org/doc/qt-4.8/qlayout.html