-2

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)
{


}
Akhil V Suku
  • 870
  • 2
  • 13
  • 34
  • I have not added any code in screen instance, I wanted to make a copy of QLayout to use in my widget class, I wanted QLayout properties only, – Akhil V Suku Dec 16 '14 at 06:08

1 Answers1

1

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

Anton Poznyakovskiy
  • 2,109
  • 1
  • 20
  • 38