Hi,
Trying to learn how to subclass a widget within a MainWindow. Inside this Widget I layed out nested under centralwidget I have a label to identify the widget box I placed. I named the widget myBoxWidget and promoted it to a class called 'myBox'. So if at this stage you try to compile the app you get an error saying mybox.h not found. So I create mybox.h and mybox.cpp with this code:
//mybox.h
#ifndef MYBOX_H
#define MYBOX_H
#include <QWidget>
{
public:
};
#endif // MYBOX_H
---------------------------------------------------------
//mybox.cpp
#include "mybox.h"
{
}
//mybox.h
#ifndef MYBOX_H
#define MYBOX_H
#include <QWidget>
class mybox : public QWidget
{
public:
mybox(QWidget *parent = 0);
};
#endif // MYBOX_H
---------------------------------------------------------
//mybox.cpp
#include "mybox.h"
mybox::mybox(QWidget *parent):QWidget(parent)
{
}
To copy to clipboard, switch view to plain text mode
Then I try to compile this and get multiple errors like:
missing ';' before '*'
and alot more errors pointing to ui_mainwindow.h
class Ui_MainWindow
{
public:
myBox *myBoxWidget;
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QStringLiteral("MainWindow"));
MainWindow->resize(400, 300);
centralWidget
= new QWidget(MainWindow
);
centralWidget->setObjectName(QStringLiteral("centralWidget"));
myBoxWidget = new myBox(centralWidget);
myBoxWidget->setObjectName(QStringLiteral("myBoxWidget"));
myBoxWidget
->setGeometry
(QRect(110,
40,
181,
141));
MainWindow->setCentralWidget(centralWidget);
class Ui_MainWindow
{
public:
QWidget *centralWidget;
myBox *myBoxWidget;
QMenuBar *menuBar;
QToolBar *mainToolBar;
QStatusBar *statusBar;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QStringLiteral("MainWindow"));
MainWindow->resize(400, 300);
centralWidget = new QWidget(MainWindow);
centralWidget->setObjectName(QStringLiteral("centralWidget"));
myBoxWidget = new myBox(centralWidget);
myBoxWidget->setObjectName(QStringLiteral("myBoxWidget"));
myBoxWidget->setGeometry(QRect(110, 40, 181, 141));
MainWindow->setCentralWidget(centralWidget);
To copy to clipboard, switch view to plain text mode
Red exclamation marks all over myBoxWidget..
What am I doing wrong??
Thanks
Bookmarks