I want to add several widgets to a single dockwidget.
As the QDockWidget owns no "addWidget" function, I managed to add a widgetForDock widget to it using "setWidget" function, and make other widgets children of the widgetForDock.
eg:
dockWidget->setWidget(widgetForDock);
dockWidget->setWidget(widgetForDock);
To copy to clipboard, switch view to plain text mode
It works well, when I make it through toward the Qt widgets, such as QLineEdit and QGroupBox. However, when I add my own object of class HistogramView, derived from QWidget, it fails to show.
eg: fail
HistogramView *histView = new HistogramView();
layout->addWidget(histView);
class HistogramView
: public QWidget{
...
public:
HistogramPlotter *histPlotter;
}
QVBoxLayout *layout = new QVBoxLayout(widgetForDock);
HistogramView *histView = new HistogramView();
layout->addWidget(histView);
class HistogramView : public QWidget
{
...
public:
HistogramPlotter *histPlotter;
QWidget *widget;
}
To copy to clipboard, switch view to plain text mode
The even odder thing is that, when I add the object histView itselft to the dockWidget, it fails, while the public members (histPlotter and widget) are added to it, it works well!
eg: works!
layout->addWidget(histView->histPlotter);
layout->addWidget(histView->widget);
layout->addWidget(histView->histPlotter);
layout->addWidget(histView->widget);
To copy to clipboard, switch view to plain text mode
The HistogramPlotter is a cumter widget, also derived from the QWidget, just as its owner object do.
Bookmarks