[Qt-interest] inheritance problem

Malyushytsky, Alex alex at wai.com
Thu Feb 25 23:57:00 CET 2010


You derive from the class you need to derive from.

If I understood your problem (which I am not sure) you want  to use your derived class instead of QTabWidget.
In this case you might use "Promoting Widgets" technique.
http://doc.trolltech.com/4.6/designer-using-custom-widgets.html

In your case:

- You subclass from the QTabWidget
- in designer place QTabWidget and then promote it.

Hope this helps,
   Alex



-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of franki
Sent: Thursday, February 25, 2010 8:11 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] inheritance problem

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
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list