当前位置: 首页>>代码示例>>C++>>正文


C++ QPainter::eraseRect方法代码示例

本文整理汇总了C++中QPainter::eraseRect方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::eraseRect方法的具体用法?C++ QPainter::eraseRect怎么用?C++ QPainter::eraseRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPainter的用法示例。


在下文中一共展示了QPainter::eraseRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: paintEvent

void Widget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QPainter painter;
    QPainterPath path;
    QPen pen(Qt::darkGray);
    painter.begin(this);
    pen.setWidth(3);
    pen.setCapStyle(Qt::RoundCap);
    pen.setJoinStyle(Qt::RoundJoin);
    painter.setBrush(Qt::darkGray);
    painter.drawRect(ui->crossBlock->x(),ui->crossBlock->y(),ui->crossBlock->width(),ui->crossBlock->height());
    pen.setColor(Qt::black);
    painter.setPen(pen);
    painter.drawLine(ui->crossBlock->x()+1,ui->crossBlock->y()+1,ui->crossBlock->x()+ui->crossBlock->width(),ui->crossBlock->y()+ui->crossBlock->height());
    painter.drawLine(ui->crossBlock->x()+1,ui->crossBlock->y()+ui->crossBlock->height(),ui->crossBlock->x()+ui->crossBlock->width(),ui->crossBlock->y()+1);
    pen.setColor(Qt::yellow);
    painter.setPen(pen);
    int mca_x = ui->mcaImage->x();
    int mca_y = ui->mcaImage->y();
    int mcb_x = ui->mcbImage->x();
    int mcb_y = ui->mcbImage->y();
    int mc_width = ui->mcaImage->width();
    int mc_height = ui->mcaImage->height();
    painter.setBrush(Qt::NoBrush);
//    painter.drawRoundedRect(mca_x,mca_y,mc_width,mc_height,5,5);
//    painter.drawRoundedRect(mcb_x,mcb_y,mc_width,mc_height,5,5);
    painter.drawRect(mca_x,mca_y,mc_width,mc_height);
    painter.drawRect(mcb_x,mcb_y,mc_width,mc_height);
//    painter.setPen(Qt::NoPen);
    painter.setBrush(Qt::NoBrush);
    painter.eraseRect(mca_x-5,mca_y-5,mc_width*0.1,mc_height*1.2);
    painter.eraseRect(mcb_x+mc_width*0.9+5,mcb_y-5,mc_width*0.1+2,mc_height*1.2);
    path.moveTo(mca_x+mc_width*0.1,mca_y);
    path.arcTo(QRectF(mca_x+mc_width*0.1-mc_height/2,mca_y,mc_height,mc_height),90,180);
    pen.setColor(Qt::yellow);
    painter.setPen(pen);
    painter.drawPath(path);
    path.moveTo(mcb_x+mc_width*0.8,mcb_y);
    path.arcTo(QRectF(mcb_x+mc_width*0.9-mc_height/2,mcb_y,mc_height,mc_height),90,-180);
    painter.drawPath(path);
    int smallRectWidth =mc_width/6;
    int smallRectHeight= mc_height/4;
    painter.setBrush(Qt::yellow);
    painter.drawRect(mca_x+mc_width*0.3-smallRectWidth,mca_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight);
    painter.drawRect(mca_x+mc_width-smallRectWidth*0.5-smallRectWidth,mca_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight);
    painter.drawRect(mca_x+mc_width*0.3-smallRectWidth,mca_y+mc_height-smallRectHeight*1.3,smallRectWidth,smallRectHeight);
    painter.drawRect(mca_x+mc_width-smallRectWidth*0.5-smallRectWidth,mca_y+mc_height-smallRectHeight*1.3,smallRectWidth,smallRectHeight);
    painter.drawRect(QRectF(mcb_x+smallRectWidth*0.5,mcb_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight));
    painter.drawRect(QRectF(mcb_x+smallRectWidth*0.5,mcb_y+mc_height-smallRectHeight*0.3-smallRectHeight,smallRectWidth,smallRectHeight));
    painter.drawRect(QRectF(mcb_x+mc_width*0.7,mcb_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight));
    painter.drawRect(QRectF(mcb_x+mc_width*0.7,mcb_y+mc_height-smallRectHeight*0.3-smallRectHeight,smallRectWidth,smallRectHeight));
    QSize Size = painter.fontMetrics().size(Qt::TextSingleLine, str);
    painter.setPen(Qt::white);
    painter.drawText(QPointF(mca_x+mc_width/2-Size.width()/2,mca_y+mc_height/2+Size.height()/2),str);
    painter.drawText(QPointF(mcb_x+mc_width/2-Size.width()/2,mcb_y+mc_height/2+Size.height()/2),str);
    painter.end();

}
开发者ID:sobang2,项目名称:Qt,代码行数:59,代码来源:widget.cpp

示例2: display

void Widget::display()
{
    delete layout();
    QSpacerItem *space1 = new QSpacerItem(100,10);
    QSpacerItem *space2 = new QSpacerItem(100,10);
    QSpacerItem *space3 = new QSpacerItem(10,10);

    QHBoxLayout *hlayout = new QHBoxLayout;
    hlayout->addSpacerItem(space1);
    hlayout->addWidget(integral);
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(numerator);
    if(this->isVisibleDenominator){
        QPixmap lineP(max(lineSizePixels((QString)numerator->text()),lineSizePixels((QString)denominator->text())),2);
        QPainter paint;
        paint.begin(&lineP);
        paint.setBrush(QBrush(Qt::black));
        paint.eraseRect(0,0,1000,1000);
        paint.drawRect(0,0,1000,1000);
        paint.end();
        line->setPixmap(lineP);
        layout->addWidget(line);
        layout->addWidget(denominator);
    }
    hlayout->addLayout(layout);
    hlayout->addSpacerItem(space3);
    hlayout->addWidget(diff);
    hlayout->addSpacerItem(space2);
    QVBoxLayout *vlayout = new QVBoxLayout;
    vlayout->addLayout(hlayout);
    vlayout->addWidget(answer);
    setLayout(vlayout);
}
开发者ID:MKorobov,项目名称:Integrals,代码行数:33,代码来源:widget.cpp

示例3: paintEvent

void CropFrame::paintEvent(QPaintEvent*)
{
    QPixmap bmp(this->width(), this->height());
    QPainter p;
    p.begin(&bmp);

    p.eraseRect(0, 0, this->width(), this->height());

    // draw the background pixmap
    p.drawPixmap(m_pixmapX, m_pixmapY, *m_pixmap);

    if (m_drawRec)
    {
        // draw the rectangle
        p.setPen(QPen(m_color, 2));
        p.drawRect(m_cropRegion);
        // draw the crosshairs
        int midX = m_cropRegion.left() + m_cropRegion.width() / 2;
        int midY = m_cropRegion.top()  + m_cropRegion.height() / 2;
        p.drawLine(midX - 10, midY, midX + 10, midY);
        p.drawLine(midX, midY - 10, midX, midY + 10);
    }
    p.end();

    QPainter newp(this);
    newp.drawPixmap(0, 0, bmp);
}
开发者ID:rickysarraf,项目名称:digikam,代码行数:27,代码来源:cropframe.cpp

示例4: resizeEvent

void PlotWidget::resizeEvent(QResizeEvent *event)
{
    double maxX=XCoord[0], maxY=YCoord[0], minX=XCoord[0], minY=YCoord[0];
    uint i;
    int longX=width()-80;
    int longY=height()-140;
    for(i=0; i< XCoord.size(); i++){
        if(minX>XCoord[i]) minX=XCoord[i];
        if(maxX<XCoord[i]) maxX=XCoord[i];
        if(minY>YCoord[i]) minY=YCoord[i];
        if(maxY<YCoord[i]) maxY=YCoord[i];
    }
    double x,y;
    imagen=QImage(longX+30,longY+30,QImage::Format_RGB32);
    QPainter painter;
    painter.begin(&imagen);
    painter.eraseRect(0,0,longX+30,longY+30);
    painter.setPen(Qt::blue);
    painter.setBrush(Qt::blue);
    for(i=0;i<=XCoord.size();i++){
        x=(XCoord[i]-minX)*longX/(maxX-minX)+30;
        y=(YCoord[i]-minY)*longY/(maxY-minY);
        painter.drawEllipse(x,longY-y,5,5);
    }
    painter.setPen(Qt::black);
    if(LinearFitEnabled){
        painter.drawLine(30,longY- ((minX*Plot_m+Plot_b)-minY)*longY/(maxY-minY),longX+30,longY-((maxX*Plot_m+Plot_b)-minY)*longY/(maxY-minY));
    }
    painter.end();
    ImageLabel->setPixmap(QPixmap::fromImage(imagen));
    //  ImageLabel->adjustSize();
    QWidget::resizeEvent(event);
}
开发者ID:nhatcher,项目名称:Clouds-Analyzer,代码行数:33,代码来源:PlotWidget.cpp

示例5: setupBuffer

void Drawboard::setupBuffer()
{
    QPixmap* newBuffer = new QPixmap(width(), height());
    QPainter* newPainter = new QPainter(newBuffer);

    newPainter->setBackgroundMode(Qt::OpaqueMode);
    newPainter->setBackground(Qt::white);

    newPainter->setRenderHint(QPainter::Antialiasing);
    newPainter->setRenderHint(QPainter::SmoothPixmapTransform);

    newPainter->eraseRect(newBuffer->rect());
    if (buffer != NULL)
    {
        int w = std::min(buffer->width(), newBuffer->width());
        int h = std::min(buffer->height(), newBuffer->height());
        newPainter->drawPixmap(0, 0, *buffer, 0, 0, w, h);
    }

    newPainter->setBrush(QColor(255, 0, 0, 128));
    newPainter->setPen(QColor(255, 0, 0, 255));

    delete painter;
    delete buffer;
    buffer = newBuffer;
    painter = newPainter;

    update();
}
开发者ID:thejk,项目名称:wiidrawboard,代码行数:29,代码来源:drawboard.cpp

示例6: paintEvent

void Graph::paintEvent(QPaintEvent *)
{
    QPainter painter;
    painter.begin(this);
    painter.setBackground(background);
    painter.eraseRect(rect());
    QPoint *points = new QPoint[MAX_DATA_LENGTH +2];
    points[0] = QPoint(0,150);
    points[MAX_DATA_LENGTH +1] = QPoint(MAX_DATA_LENGTH,150);
    for (int s = 0; s < MAX_DATA_LENGTH; s++){
        points[s +1] = QPoint(s,100 - data.at(data.length() - s -1));
    }
    painter.setPen(gridPen);
    painter.setBrush(filler);
    for (int s = 0; s < MAX_DATA_LENGTH / 30; s++){
        painter.drawLine(MAX_DATA_LENGTH - 30 * (s+1), 0,MAX_DATA_LENGTH - 30 * (s+1), 100);
    }
    for (int s = 0; s < 10; s++){
        painter.drawLine(0, 10*s,MAX_DATA_LENGTH, 10*s);
    }
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(circlePen);
    painter.drawPolygon(points,MAX_DATA_LENGTH +2);
    painter.end();
    delete points;
}
开发者ID:Raffarti,项目名称:SimpleOverGraph,代码行数:26,代码来源:graph.cpp

示例7: DECOFUNC

//Input Port #0: Buffer_Size = 1, Params_Type = ProcessorMulti_Processor_Control_Params, Data_Type = ProcessorMulti_Processor_Control_Data
//Input Port #1: Buffer_Size = 1, Params_Type = SensorInternalEvent_Sensor_Joystick_Params, Data_Type = SensorInternalEvent_Sensor_Joystick_Data
bool DECOFUNC(processMultiDrainData)(void * paramsPtr, void * varsPtr, QVector<QVector<void *> > drainParams, QVector<QVector<void *> > drainData)
{
	VisualizationMulti_VisualMisc_ControlJoy_Params * params=(VisualizationMulti_VisualMisc_ControlJoy_Params *)paramsPtr;
	VisualizationMulti_VisualMisc_ControlJoy_Vars * vars=(VisualizationMulti_VisualMisc_ControlJoy_Vars *)varsPtr;
	QVector<ProcessorMulti_Processor_Control_Params *> drainparams_0; copyQVector(drainparams_0,drainParams[0]);
	QVector<SensorInternalEvent_Sensor_Joystick_Params *> drainparams_1; copyQVector(drainparams_1,drainParams[1]);
	QVector<ProcessorMulti_Processor_Control_Data *> draindata_0; copyQVector(draindata_0,drainData[0]);
	QVector<SensorInternalEvent_Sensor_Joystick_Data *> draindata_1; copyQVector(draindata_1,drainData[1]);
	if(draindata_0.size()==0){return 0;}
	if(draindata_1.size()==0){return 0;}
	/*======Please Program below======*/
	/*
	Function: process draindata_index.
	*/
    ProcessorMulti_Processor_Control_Data* controldata = draindata_0.front();
    SensorInternalEvent_Sensor_Joystick_Data* joystick_data = draindata_1.front();

    if(controldata->isManualControl == 1)//manual control
    {
        QImage image(vars->width, vars->height, QImage::Format_ARGB32);

        QPainter painter;

        //vars->joystick_label->resize(vars->width, vars->height);
        painter.begin(&image);
        painter.setBackground(QBrush(QColor(241,241,241)));
        painter.eraseRect(0,0, vars->width, vars->height);

         if(joystick_data->forward)
            painter.drawImage(vars->width/2-16, vars->height/2-56, vars->forwardArrowImg);

        if(joystick_data->left)
            painter.drawImage(vars->width/2 -56, vars->height/2-16, vars->leftArrowImg);

        if(joystick_data->right)
            painter.drawImage(vars->width/2+24, vars->height/2-16, vars->rightArrowImg);

        if(joystick_data->back)
            painter.drawImage(vars->width/2-16, vars->height/2+24, vars->backArrowImg);
        painter.end();

        vars->label->setPixmap(QPixmap::fromImage(image));
    }
    else //Auto control
    {
        QFont serifFont("Times", vars->fontSize);
        vars->label->setFont(serifFont);
        QPalette pa;
        pa.setColor(QPalette::WindowText,Qt::red);
        vars->label->setPalette(pa);
        //vars->label->setAlignment(Qt::AlignLeft);

        QString outputstr = QString("Left_Motor: %1\nRight_Motor: %2\n").arg(controldata->left_motor).arg(controldata->right_motor);
        vars->label->setText(outputstr);
    }

    //vars->label->setFixedHeight(250);
	return 1;
}
开发者ID:dog2cat,项目名称:autowheel,代码行数:61,代码来源:VisualizationMulti_VisualMisc_ControlJoy_PrivFunc.cpp

示例8: mouseReleaseEvent

void RubberbandWidget::mouseReleaseEvent( QMouseEvent* )
{
    if ( on ) {
	QPainter p ( this );
	p.eraseRect( rect() );
    }
    on = FALSE;
    setMouseTracking( FALSE );
}
开发者ID:nightfly19,项目名称:renyang-learn,代码行数:9,代码来源:rubberbandwidget.cpp

示例9: drawContent

void WLinePlot::drawContent(QPainter &p, bool completeRedraw) {

    completeRedraw=true;

    QArray<float>::Iterator xIt, yIt;

    p.eraseRect(p.window());

    if (!traces.isEmpty() && xData.count()>0) {

        if (wrapAround) {

            p.setPen(SolidLine);

            // cycle traces and draw them
            for (WGraphTrace *trace=traces.first();
                    trace !=0; trace=traces.next())
                if (trace->isVisible()) {

                    p.setPen(trace->getPen());

                    xIt=xData.begin();
                    yIt=trace->getData().begin();
                    p.moveTo(mapToViewCoords(*xIt,*yIt));
                    for (++xIt, ++yIt; xIt<xData.end(); ++xIt, ++yIt)
                        p.lineTo(mapToViewCoords(*xIt,*yIt));
                }

            // drawing new cursor at newPos+1
            if (cursorPos<traceLength()-1) {
                int x1 = mapToViewCoords(xData[cursorPos],0).x();
                int x2 = mapToViewCoords(xData[cursorPos+1],0).x()+1;
                p.fillRect(x1,p.window().top(),x2-x1,p.window().height(),red);
            }
        } else {

            float *x=xData.data(), *y;

            for (WGraphTrace *trace=traces.first();
                    trace !=0; trace=traces.next())
                if (trace->isVisible()) {

                    y=trace->getData().data();

                    p.setPen(trace->getPen());
                    p.moveTo(mapToViewCoords(x[0],y[(cursorPos+1) %
                                                    traceLength()]));

                    for (int i=1; i<traceLength(); i++)
                        p.lineTo(mapToViewCoords(x[i],y[(i+cursorPos+1) %
                                                        traceLength()]));
                }
        }
    }
}
开发者ID:jeez,项目名称:iqr,代码行数:55,代码来源:wLinePlot.cpp

示例10: paintEvent

void MapPanel::paintEvent(QPaintEvent *)
{

    QPainter painter;
    painter.begin(this);
    painter.eraseRect(0,0,width(),height());
    painter.translate(off_x,off_y);
    painter.scale(scale,scale);
    painter.drawImage(0,0,mapMagager.getImage());
    painter.end();
}
开发者ID:zhangxuran11,项目名称:GPSMapDemo,代码行数:11,代码来源:mappanel.cpp

示例11: paintEvent

void SVGFrame::paintEvent ( QPaintEvent* event )
{
	if ( repaint && !drawImg && !empty )
	{
		QPainter p ( this );
		p.setViewport ( 0, 0, width(), height() );
		p.eraseRect ( 0, 0, width(), height() );
		renderer->render ( &p );
	}
	QFrame::paintEvent ( event );
}
开发者ID:obalci,项目名称:x2goclient,代码行数:11,代码来源:SVGFrame.cpp

示例12: clearRect

void GraphicsContext::clearRect(const FloatRect& rect)
{
    if (paintingDisabled())
        return;

    QPainter *p = m_data->p();
    QPainter::CompositionMode currentCompositionMode = p->compositionMode();
    p->setCompositionMode(QPainter::CompositionMode_Source);
    p->eraseRect(rect);
    p->setCompositionMode(currentCompositionMode);
}
开发者ID:pk-codebox-evo,项目名称:remixos-usb-tool,代码行数:11,代码来源:GraphicsContextQt.cpp

示例13: exportImage

//イメージファイルの出力
bool SXBSchView::exportImage(const QString& fname)
{
    m_pDoc->resetSelect();
    updateViewBuffer(true);

    int w = SheetSize().width();
    int h = SheetSize().height();

    QPixmap buffer(w,h);

    QPainter painter;
    painter.begin(&buffer);
    QRect rcClip = QRect(0,0,w,h);
    SRect srcClip =SRect(0,0,w,h);

    //    int currentScale = m_viewScale;
    //    int currentScaleMul = m_viewScaleMul;

    //    m_viewScale = 1;
    //    m_viewScaleMul = 1;
    SSize size = m_pDoc->SheetSize();

    //#ifdef _WINDOWS
    //    painter.setBackgroundColor(Qt::color0);
    //    painter.eraseRect(0,0,w,h);
    //    g_drawFrame(&painter,size,rcClip,Qt::color1,1,1);
    //    drawMainXBSchObj(&painter,DRAW_MONO,&srcClip,1,1);
    //#else
    painter.setBackground(Qt::white);
    painter.eraseRect(0,0,w,h);
    g_drawFrame(&painter,size,rcClip,Qt::black,1,1);
    //    drawMainXBSchObj(&painter,DRAW_ON,&srcClip);

    QSettings *settings = g_cfg.getSettings();
    settings->beginGroup("PrintOption");
    bool color = settings->value("Color",true).toBool();
    settings->endGroup();
    drawMainXBSchObj(&painter,(color ? DRAW_ON : DRAW_MONO),&srcClip,false,1,1);
    //#endif
    //    m_viewScale = currentScale;
    //    m_viewScaleMul = currentScaleMul;
    bool result = buffer.save(fname);


    //qDebug("SXBSchView::exportImage(const QString& fname)");

    update();    //画面の更新を強制
    return result;
}
开发者ID:hermixy,项目名称:Qt-BSch3V-Modified,代码行数:50,代码来源:xbschview.cpp

示例14: CreatePixmap

QPixmap QSettingColorTableItem::CreatePixmap() const
{
	if (m_pSetting == NULL || (m_pSetting->GetType() & 0xF) != Setting::SettingTypeColor)
		return QPixmap();
	else
	{
		QPixmap bmpImage(sizeHint().height() - 4, sizeHint().height() - 4);
		QPainter dcImage;
		QColor clrBackground(m_pSetting->GetValue().strValue);
		dcImage.begin(&bmpImage, table()->viewport());
		dcImage.setBackgroundColor(clrBackground.isValid() ? clrBackground : QColor(0, 0, 0));
		dcImage.eraseRect(bmpImage.rect());
		dcImage.drawRect(bmpImage.rect());
		dcImage.end();
		return bmpImage;
	}
}
开发者ID:vigneshananth,项目名称:Groovenet-Qt4,代码行数:17,代码来源:QSettingColorTableItem.cpp

示例15: doPaint

void doPaint(QPainter & p)
{
    QRgb rgb = qRgb(161, 161, 161);

    p.setBackground(QBrush(rgb));
    p.eraseRect(0, 0, LCD_W, LCD_H);

    if (1) {
#if !defined(PCBTARANIS)
        rgb = qRgb(0, 0, 0);
        p.setPen(rgb);
        p.setBrush(QBrush(rgb));
#endif

#if defined(PCBTARANIS)
        unsigned int previousDepth = 0xFF;
#endif

        for (int y=0; y<LCD_H; y++) {
#if defined(PCBTARANIS)
            unsigned int idx = (y/2) * LCD_W;
#else
            unsigned int idx = (y/8) * LCD_W;
            unsigned int mask = (1 << (y%8));
#endif
            for (int x=0; x<LCD_W; x++, idx++) {
#if !defined(PCBTARANIS)
                if (lcd_buf[idx] & mask) {
                    p.drawPoint(x, y);
                }
#else
                unsigned int z = (y & 1) ? (lcd_buf[idx] >> 4) : (lcd_buf[idx] & 0x0F);
                if (z) {
                    if (z != previousDepth) {
                        previousDepth = z;
                        rgb = qRgb(161-(z*161)/15, 161-(z*161)/15, 161-(z*161)/15);
                        p.setPen(rgb);
                        p.setBrush(QBrush(rgb));
                    }
                    p.drawPoint(x, y);
                }
#endif
            }
        }
    }
开发者ID:Paul-NA8E,项目名称:opentx,代码行数:45,代码来源:lcd.cpp


注:本文中的QPainter::eraseRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。