本文整理汇总了C++中QwtPlotCanvas::setFocusPolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotCanvas::setFocusPolicy方法的具体用法?C++ QwtPlotCanvas::setFocusPolicy怎么用?C++ QwtPlotCanvas::setFocusPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotCanvas
的用法示例。
在下文中一共展示了QwtPlotCanvas::setFocusPolicy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QObject
CanvasPicker::CanvasPicker( QwtPlot *plot ):
QObject( plot ),
d_selectedCurve( NULL ),
d_selectedPoint( -1 )
{
QwtPlotCanvas *canvas = qobject_cast<QwtPlotCanvas *>( plot->canvas() );
canvas->installEventFilter( this );
// We want the focus, but no focus rect. The
// selected point will be highlighted instead.
canvas->setFocusPolicy( Qt::StrongFocus );
#ifndef QT_NO_CURSOR
canvas->setCursor( Qt::PointingHandCursor );
#endif
canvas->setFocusIndicator( QwtPlotCanvas::ItemFocusIndicator );
canvas->setFocus();
const char *text =
"All points can be moved using the left mouse button "
"or with these keys:\n\n"
"- Up:\t\tSelect next curve\n"
"- Down:\t\tSelect previous curve\n"
"- Left, ´-´:\tSelect next point\n"
"- Right, ´+´:\tSelect previous point\n"
"- 7, 8, 9, 4, 6, 1, 2, 3:\tMove selected point";
canvas->setWhatsThis( text );
shiftCurveCursor( true );
}
示例2: QObject
CanvasPicker::CanvasPicker(Plot *plot):
QObject(plot),
d_selectedCurve(NULL),
d_selectedPoint(-1)
{
qDebug() << __FILE__ << __FUNCTION__;
QwtPlotCanvas *canvas = (QwtPlotCanvas*) plot->canvas();
canvas->installEventFilter(this);
// We want the focus, but no focus rect. The
// selected point will be highlighted instead.
canvas->setFocusPolicy(Qt::StrongFocus);
#ifndef QT_NO_CURSOR
canvas->setCursor(Qt::PointingHandCursor);
#endif
canvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator);
canvas->setFocus();
mousePressed = false;
accelerate = 0;
}
示例3: QObject
CanvasPicker::CanvasPicker( QwtPlot* plot ): QObject( plot ), m_isEnabled( false ), m_dragAndDropInProgress( false ),
m_typeOfItemsToDrag( -1 ), m_itemToPick( 0 )
{
QwtPlotCanvas* canvas = qobject_cast<QwtPlotCanvas*>( plot->canvas() );
canvas->installEventFilter( this );
m_isEnabled = true;
canvas->setFocusPolicy( Qt::StrongFocus );
canvas->setFocusIndicator( QwtPlotCanvas::ItemFocusIndicator );
canvas->setFocus();
}
示例4: QwtPlotPicker
LineChartPicker::LineChartPicker(QwtPlot *plot) :
QwtPlotPicker(plot->canvas()),
p(plot)
{
QwtPlotCanvas *canvas = plot->canvas();
canvas->installEventFilter(this);
canvas->setFocusPolicy(Qt::StrongFocus);
canvas->setMouseTracking(true);
canvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator);
canvas->setFocus();
}
示例5: QwtPlot
Plot::Plot(QWidget *parent, const char *name)
: QwtPlot(parent)
{
marker_key = 0;
curve_key = 0;
minTickLength = 5;
majTickLength = 9;
movedGraph=FALSE;
graphToResize=FALSE;
ShiftButton=FALSE;
setGeometry(QRect(0,0,500,400));
setAxisTitle(QwtPlot::yLeft, tr("Y Axis Title"));
setAxisTitle(QwtPlot::xBottom, tr("X Axis Title"));
// grid
d_grid = new Grid;
d_grid->enableX(false);
d_grid->enableY(false);
d_grid->setMajPen(QPen(Qt::blue, 0, Qt::SolidLine));
d_grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
d_grid->attach(this);
//custom scale
for (int i= 0; i<QwtPlot::axisCnt; i++)
{
QwtScaleWidget *scale = (QwtScaleWidget *) axisWidget(i);
if (scale)
{
scale->setMargin(0);
//the axis title color must be initialized
QwtText title = scale->title();
title.setColor(Qt::black);
scale->setTitle(title);
ScaleDraw *sd = new ScaleDraw();
sd->setTickLength (QwtScaleDiv::MinorTick, minTickLength);
sd->setTickLength (QwtScaleDiv::MediumTick, minTickLength);
sd->setTickLength (QwtScaleDiv::MajorTick, majTickLength);
setAxisScaleDraw (i, sd);
}
}
QwtPlotLayout *pLayout=plotLayout();
pLayout->setCanvasMargin(0);
QwtPlotCanvas* plCanvas = canvas();
plCanvas->setFocusPolicy(QWidget::StrongFocus);
plCanvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator);
plCanvas->setFocus();
plCanvas->setFrameShadow(QwtPlot::Plain);
plCanvas->setCursor(Qt::arrowCursor);
plCanvas->setLineWidth(0);
setFocusPolicy(QWidget::StrongFocus);
setFocusProxy(plCanvas);
setFrameShape (QFrame::Box);
setLineWidth(0);
}
示例6: QwtPlot
Plot::Plot(int width, int height, QWidget *parent, const char *)
: QwtPlot(parent)
{
setAutoReplot (false);
marker_key = 0;
curve_key = 0;
minTickLength = 5;
majTickLength = 9;
setGeometry(QRect(0, 0, width, height));
setAxisTitle(QwtPlot::yLeft, tr("Y Axis Title"));
setAxisTitle(QwtPlot::xBottom, tr("X Axis Title"));
//due to the plot layout updates, we must always have a non empty title
setAxisTitle(QwtPlot::yRight, tr(" "));
setAxisTitle(QwtPlot::xTop, tr(" "));
// grid
d_grid = new Grid();
d_grid->attach(this);
//custom scale
for (int i= 0; i<QwtPlot::axisCnt; i++) {
QwtScaleWidget *scale = (QwtScaleWidget *) axisWidget(i);
if (scale) {
scale->setMargin(0);
//the axis title color must be initialized...
QwtText title = scale->title();
title.setColor(Qt::black);
scale->setTitle(title);
//...same for axis color
QPalette pal = scale->palette();
pal.setColor(QPalette::Foreground, QColor(Qt::black));
scale->setPalette(pal);
ScaleDraw *sd = new ScaleDraw(this);
sd->setTickLength(QwtScaleDiv::MinorTick, minTickLength);
sd->setTickLength(QwtScaleDiv::MediumTick, minTickLength);
sd->setTickLength(QwtScaleDiv::MajorTick, majTickLength);
setAxisScaleDraw (i, sd);
setAxisScaleEngine (i, new ScaleEngine());
}
}
QwtPlotLayout *pLayout = plotLayout();
pLayout->setCanvasMargin(0);
pLayout->setAlignCanvasToScales (true);
QwtPlotCanvas* plCanvas = canvas();
plCanvas->setFocusPolicy(Qt::StrongFocus);
plCanvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator);
//plCanvas->setFocus();
plCanvas->setFrameShadow(QwtPlot::Plain);
plCanvas->setCursor(Qt::arrowCursor);
plCanvas->setLineWidth(0);
plCanvas->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
plCanvas->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
QColor background = QColor(Qt::white);
background.setAlpha(255);
QPalette palette;
palette.setColor(QPalette::Window, background);
setPalette(palette);
setCanvasBackground (background);
setFocusPolicy(Qt::StrongFocus);
//setFocusProxy(plCanvas);
setFrameShape(QFrame::Box);
setLineWidth(0);
}
示例7: canvasPalette
Plot::Plot( QWidget *parent ):
QwtPlot( parent )
{
//setAutoFillBackground( true );
//setPalette( QPalette( QColor( 165, 193, 228 ) ) );
//updateGradient();
//setTitle( "A Simple QwtPlot Demonstration" );
//insertLegend( new QwtLegend(), QwtPlot::BottomLegend );
// axes
setAxisTitle( xBottom, "x -->" );
setAxisScale( xBottom, 0.0, 360.0 );
setAxisTitle( yLeft, "y -->" );
setAxisScale( yLeft, -10.0, 10.0 );
// canvas
QwtPlotCanvas *canvas = new QwtPlotCanvas();
//canvas->setLineWidth( 1 );
canvas->setFrameStyle( QFrame::StyledPanel );
//canvas->setBorderRadius( 15 );
QwtPlotGrid* grid = new QwtPlotGrid();
grid->setPen(Qt::black, 0.1, Qt::DashLine);
grid->attach(this);
QPalette canvasPalette( Qt::white );
canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
canvas->setPalette( canvasPalette );
setCanvas( canvas );
// panning with the left mouse button
QwtPlotPanner* panner = new QwtPlotPanner( canvas );
panner->setMouseButton(Qt::LeftButton, Qt::ControlModifier);
// zoom in/out with the wheel
QwtPlotMagnifier* magnifier = new QwtPlotMagnifier( canvas );
magnifier->setAxisEnabled(xBottom, false);
QwtPlotZoomer* zoomer = new QwtPlotZoomer(canvas);
zoomer->setKeyPattern( QwtEventPattern::KeyRedo, Qt::Key_I, Qt::ShiftModifier );
zoomer->setKeyPattern( QwtEventPattern::KeyUndo, Qt::Key_O, Qt::ShiftModifier );
zoomer->setKeyPattern( QwtEventPattern::KeyHome, Qt::Key_Home );
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ShiftModifier);
canvas->setFocusPolicy(Qt::StrongFocus);
canvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator);
canvas->setFocus();
//canvas->setFrameShadow(QwtPlot::Plain);
//canvas->setCursor(Qt::arrowCursor);
canvas->setLineWidth(0);
//canvas->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
//canvas->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
//populate();
}