I have:
{
...
setCentralWidget(workspace_);
...
}
void MyMainWindow::createChild()
{
...
child = new MyTool();
workspace_->addWindow(child);
child->show()
}
{
...
setCentralWidget(scrollArea_);
scrollArea_->setWidgetResizable ( true );
scrollArea_->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
scrollArea_->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
scrollAreaGridLayout_->addWidget(scrollAreaWidget_, 0, 1, 1, 1);
scrollArea_->setWidget(scrollAreaWidget_);
scrollAreaGridLayout2_
= new QGridLayout(scrollAreaWidget_
);
scrollAreaGridLayout2_->addWidget(tabWidget_, 0, 1, 1, 1);
tabWidget_->setEnabled(true);
...
}
class MyMainWindow : public QMainWindow
MyMainWindow::MyMainWindow() : QMainWindow(0,0)
{
...
workspace_ = new QWorkspace();
setCentralWidget(workspace_);
...
}
void MyMainWindow::createChild()
{
...
child = new MyTool();
workspace_->addWindow(child);
child->show()
}
class MyTool : public QMainWindow
MyTool::MyTool(QWidget * parent) : QMainWindow(parent,0)
{
...
scrollArea_ = new QScrollArea;
setCentralWidget(scrollArea_);
scrollArea_->setWidgetResizable ( true );
scrollArea_->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
scrollArea_->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
scrollAreaGridLayout_ = new QGridLayout(scrollArea_);
scrollAreaWidget_ = new QWidget();
scrollAreaGridLayout_->addWidget(scrollAreaWidget_, 0, 1, 1, 1);
scrollArea_->setWidget(scrollAreaWidget_);
tabWidget_ = new QTabWidget();
scrollAreaGridLayout2_ = new QGridLayout(scrollAreaWidget_);
scrollAreaGridLayout2_->addWidget(tabWidget_, 0, 1, 1, 1);
tabWidget_->setEnabled(true);
...
}
To copy to clipboard, switch view to plain text mode
The tabWidget_ will eventually display Profile - a class that contains a plot:
{
...
graphicDisplay = new ProfileGraphicDisplay(this);
...
}
class ProfileGraphicDisplay
: public QwtPlot
ProfileGraphicDisplay
::ProfileGraphicDisplay (QWidget *parent
) : QwtPlot(parent
){
...
canvas1_ = canvas();
canvas1_->installEventFilter(this);
canvas1_->setCursor(Qt::PointingHandCursor);
canvas1_->setFocus();
canvas1Picker_
->setTrackerPen
(QColor(Qt
::black));
canvas1Picker_
->setSelectionFlags
( QwtPicker::PointSelection |
QwtPicker::DragSelection );
canvas1Picker_
->setTrackerMode
( QwtPicker::AlwaysOff );
connect( canvas1Picker_, SIGNAL( selected( const QwtDoublePoint & ) ), this, SLOT( pointSelected( const QwtDoublePoint & ) ) );
canvas1Zoomer_
->setSelectionFlags
( QwtPicker::DragSelection );
canvas1Zoomer_
->setTrackerMode
(QwtPicker::ActiveOnly);
curve1_->setData( xProfile_, yProfile_ );
...
}
class Profile : public QWidget
Profile::Profile(QWidget * parent) : QWidget(parent)
{
...
graphicDisplay = new ProfileGraphicDisplay(this);
...
}
class ProfileGraphicDisplay : public QwtPlot
ProfileGraphicDisplay ::ProfileGraphicDisplay (QWidget *parent) : QwtPlot(parent)
{
...
canvas1_ = canvas();
canvas1_->installEventFilter(this);
canvas1_->setCursor(Qt::PointingHandCursor);
canvas1_->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator);
canvas1_->setFocus();
canvas1Picker_ = new QwtPlotPicker( canvas1_ );
canvas1Picker_->setTrackerPen(QColor(Qt::black));
canvas1Picker_->setSelectionFlags( QwtPicker::PointSelection | QwtPicker::DragSelection );
canvas1Picker_->setTrackerMode( QwtPicker::AlwaysOff );
connect( canvas1Picker_, SIGNAL( selected( const QwtDoublePoint & ) ), this, SLOT( pointSelected( const QwtDoublePoint & ) ) );
canvas1Zoomer_ = new QwtPlotZoomer( QwtPlot::xBottom, QwtPlot::yLeft, canvas1_ );
canvas1Zoomer_->setSelectionFlags( QwtPicker::DragSelection );
canvas1Zoomer_->setTrackerMode(QwtPicker::ActiveOnly);
curve1_ = new QwtPlotCurve();
curve1_->setData( xProfile_, yProfile_ );
...
}
To copy to clipboard, switch view to plain text mode
So, When I use canvas1Zoomer_ to zoom in the ProfileGraphicDisplay area, MyTool window moves inside workspace_.
Bookmarks