[Qt-interest] inheritance problem

franki franki at franki.eu.org
Thu Feb 25 17:11:23 CET 2010


Hi,

I've application with QMainWindow and tabWidget as a centralWidget,
class that maintains this tabWidget is called custPanel_TabWidget
some piece of custpanel.h:

#ifndef CUSTPANEL_H
#define CUSTPANEL_H
#include "ui_custpanel.h"

class custPanel_TabWidget: public QTabWidget
{
        Q_OBJECT
public:
        custPanel_TabWidget (QWidget *parent,QVariant cust_id,ItSql *itsql);
        ~custPanel_TabWidget();
        Ui::custPanel_TabWidget cp;
}

I wanted each tab to be maintained by its own class, because there is so many 
functions that custPanel_TabWidget started to be huge mess.
so I did class e.g. Notify
header notify.h:

#ifndef NOTIFY_H
#define NOTIFY_H
#include <QObject>
#include "custpanel.h"

class custPanel_TabWidget;

class Notify: public custPanel_TabWidget
{
public:
        Notify ();
        ~Notify();
};

but during compilation, I get error:
invalid use of incomplete type 'struct custPanel_TabWidget'

I've googled somewhere that I should derive from Ui::custPanel_TabWidget 
instead of custPanel_TabWidget, because this class is called that way in 
ui_custpanel.h - which is true.
But, when I've tried to derive from Ui::custPanel_TabWidget, program compile 
fine, but I can't access any widget on tabWidget, and in fact which class do 
I derive from?

Second sollution for me, that I've proven to work earlier, was to pass some 
variables to new class instead of deriving from custPanel_TabWindow, and 
maintain all function related to this tab in that new class.
So in that case, the constructor is like this:

Abonament::Abonament(Ui::custPanel_TabWidget cp,ItSql *itsql,QVariant 
cust_id,custPanel_TabWidget *parent) : QWidget ()

And this second approach works fine for me, but which one is better, or which 
one is recommended?

Thanks in advance
Marek



More information about the Qt-interest-old mailing list