Hello. In my program is the class MainWindow, which is inherited from QMainWindow. Is it possible to create another class, which would be the heir to MainWindow. I want to create objects by these classes in main.cpp and call methods. Just when I attempted such an implementation methods successor from MainWindow not performed.
.h
{
Q_OBJECT
public:
}
class OptionPlot : public MainWindow
{
Q_OBJECT
public:
...
}
class MainWindow : public QMainWindow
{
Q_OBJECT
QWidget *centralWidget;
public:
MainWindow (QWidget* parent=0);
QwtPlot *funPlot;
}
class OptionPlot : public MainWindow
{
Q_OBJECT
public:
OptionPlot (QWidget* parent=0);
...
}
To copy to clipboard, switch view to plain text mode
.cpp
...
MainWindow::MainWindow(QWidget *parent
): }
OptionPlot
:OptionPlot
(QWidget *parent
):MainWindow(parent) {
}
...
// implementation of methods MainWindow class and OptionPlot further
...
MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent) {
funPlot = new QwtPlot(this);
}
OptionPlot:OptionPlot(QWidget *parent):
MainWindow(parent) {
}
...
// implementation of methods MainWindow class and OptionPlot further
To copy to clipboard, switch view to plain text mode
main.cpp
...
MainWindow *window = new MainWindow;
OptionPlot *option1 = new OptionPlot;
window->setPlot();
window->setGrid();
window->createMenu();
option1->setCurve();
option1->addPoints();
option1->setCheckBox();
...
return app.exec();
...
QApplication app(argc, argv);
MainWindow *window = new MainWindow;
OptionPlot *option1 = new OptionPlot;
window->setPlot();
window->setGrid();
window->createMenu();
option1->setCurve();
option1->addPoints();
option1->setCheckBox();
...
return app.exec();
To copy to clipboard, switch view to plain text mode
The window is created, the grid and the menu too, but CheckBoxes and graphics isn't. What is a mistake of that realization?
Bookmarks