How do I inherit the ui of a class?
-
I am wanting to set up a User Interface form class, so that the class has some of the form elements on it and some of the underlying code. As it is a base class the more specific design/functionality taking place in the classes inheriting from it. I also want it to have pure virtual methods and that are implemented in the classes that inherit from it, but use it properties and ui elements.
The problem I am having is that though I have made ui protected I still can't use it in the inheriting class.
The base class is inherited as public and my code can see the protected properties I have defined in the base class.
I want the base class to define the form layout with a tableview, some fields and some buttons. I then want to be able to use the virtual methods to populate the tableview and then on selecting a record in the table view (populated with data from a database), put that in a form element that the child class has added to the parents dialogue. I have added a frame to the ui in the base class in which to put this.
My question is how do I access the ui elements of the base class within the child class?
I have tried using ui and it accepted (the complier doesn't suggest its undefined), but it doesn't do anything. I have tried using "this", but it doesn't give me the fields I defined in the base class.
I have search for this and all I could find was something in Stackoverflow that was considered unsafe by other contributors.
Top of Base class.
@namespace Ui {
class List_Dialog;
}
class List_Dialog : public QDialog
{
Q_OBJECT
public:
explicit List_Dialog(database *db, QWidget parent = 0);
/! \brief Class Destructor. */
~List_Dialog();
private slots:protected:
/*! Pointer to the dialogue user interface. */
Ui::List_Dialog ui;
/! Pointer to the database class. */
database *m_db;@Top of Child Class.
@#include <QtGui>
#include "list_dialog.h"
#include "database.h"
class InsulinList_Dialog : public List_Dialog
{
Q_OBJECT
public:
explicit InsulinList_Dialog(database *db, QWidget *parent = 0);@Any help would be appreciated.
-
I hadn't included the Ui namespace, I added that and it now I can access the ui elements but the Canel button, that worked prior, to making his alteration now doesn't work any more. This button isn't Virtual, it just lives in the base class.
@namespace Ui {
class InsulinList_Dialog;
}@The Cancel button was set up by right clicking on the button and going to the slot from there, the method exists, it just doesn't work. If I try and recreate it I get the following message.
bq. The class containing 'Ui::List_Dialog' could not be found in
/home/mike/Projects/DiabeticConsole Project/DiabeticConsole/list_dialog.h
/home/mike/Projects/DiabeticConsole Project/DiabeticConsole/list_dialog.cpp
/home/mike/Projects/DiabeticConsole Project/DiabeticConsole/insulinlist_dialog.cpp.
Please verify the #include-directives.bq.What am I missing with the include directives, of can anyone suggest a How To for inheriting from a form class?