sai
25th November 2008, 02:59
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);
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
QVBoxLayout *layout = new QVBoxLayout(widgetForDock);
HistogramView *histView = new HistogramView();
layout->addWidget(histView);
class HistogramView : public QWidget
{
...
public:
HistogramPlotter *histPlotter;
QWidget *widget;
}
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);
The HistogramPlotter is a cumter widget, also derived from the QWidget, just as its owner object do.
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);
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
QVBoxLayout *layout = new QVBoxLayout(widgetForDock);
HistogramView *histView = new HistogramView();
layout->addWidget(histView);
class HistogramView : public QWidget
{
...
public:
HistogramPlotter *histPlotter;
QWidget *widget;
}
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);
The HistogramPlotter is a cumter widget, also derived from the QWidget, just as its owner object do.