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


C++ QPainterPath::addRoundRect方法代码示例

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


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

示例1: initModifyStation

/*==================================================================*/
void ModifyStation::initModifyStation(int no)
{
	setModal(true);
	setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint 
		| Qt::WindowMinimizeButtonHint
		| Qt::WindowMaximizeButtonHint);

	//setAttribute(Qt::WA_DeleteOnClose);

	this->setAutoFillBackground(true);
	QPalette palette;
	palette.setColor(QPalette::Background, QColor(35,202,255));
	this->setPalette(palette);

	QPainterPath path;
	QRectF rect = QRectF(this->rect());
	path.addRoundRect(rect,10,10);
	QPolygon polygon= path.toFillPolygon().toPolygon();
	QRegion region(polygon);
	setMask(region);

	//当点击确定时,执行的槽函数为ok
	connect(ui.okButton, SIGNAL(clicked()), this, SLOT(ok()));

	//记录当前焦点所在采集站的编号
	index = no;

	//读取已有的配置或增加新配置
	readIni(no);
}
开发者ID:unix8net,项目名称:MoniterV2,代码行数:31,代码来源:modifystation.cpp

示例2: paint

  void TOPPASOutputFileListVertex::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/)
  {
    QPen pen(pen_color_, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
    if (isSelected())
    {
      pen.setWidth(2);
      painter->setBrush(brush_color_.darker(130));
      pen.setColor(Qt::darkBlue);
    }
    else
    {
      painter->setBrush(brush_color_);
    }
    painter->setPen(pen);

    QPainterPath path;
    path.addRoundRect(-70.0, -40.0, 140.0, 80.0, 20, 20);
    painter->drawPath(path);

    pen.setColor(pen_color_);
    painter->setPen(pen);
    QString text =  QString::number(files_written_) + "/"
                   + QString::number(files_total_) + " output file" + (files_total_ == 1 ? "" : "s");
    QRectF text_boundings = painter->boundingRect(QRectF(0, 0, 0, 0), Qt::AlignCenter, text);
    painter->drawText(-(int)(text_boundings.width() / 2.0), (int)(text_boundings.height() / 4.0), text);

    // display file type(s)
    Map<QString, Size> suffices;
    foreach(QString fn, getFileNames())
    {
      QStringList l = QFileInfo(fn).completeSuffix().split('.');
      QString suf = ((l.size() > 1 && l[l.size() - 2].size() <= 4) ? l[l.size() - 2] + "." : QString()) + l.back(); // take up to two dots as suffix (the first only if its <=4 chars, e.g. we want ".prot.xml" or ".tar.gz", but not "stupid.filename.with.longdots.mzML")
      ++suffices[suf];
    }
开发者ID:sneumann,项目名称:OpenMS,代码行数:34,代码来源:TOPPASOutputFileListVertex.C

示例3: paintEvent

void MenuListWidget::paintEvent(QPaintEvent *event) {
    Q_UNUSED(event);
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing, true);//启用反走样以得到平滑的边缘
    painter.setPen(QColor("#FDFDFD"));
    painter.setBrush(QColor("#FDFDFD"));

    painter.save();

    QRect bgRect = rect();
    bgRect.setWidth(rect().width());
    bgRect.setHeight(rect().height());
    painter.drawRect(bgRect);

    painter.restore();

    QPainterPath path;
    path.addRoundRect(0, 8, 185, 8+_displayCount*52, 10);
    path.moveTo(172, 0);
    path.lineTo(172-5, 8);
    path.lineTo(172+5, 8);

//    painter.setPen(QColor("#0f9d58"));
//    painter.setBrush(QColor("#0f9d58"));
    painter.setPen(Qt::transparent);
    painter.setBrush(Qt::transparent);
    painter.drawPath(path);
    painter.fillPath(path, QColor(255,255,255,128));
}
开发者ID:liduoyou,项目名称:FBSV3,代码行数:29,代码来源:MenuListWidget.cpp

示例4: node

QPainterPath Paths::node()
{
    QRectF m_rect;
    m_rect.setWidth(150);
    m_rect.setHeight(100);

    QPainterPath shape;
    shape.addRoundRect(m_rect, 25);

    const int conWidth = 10;
    const int xOffset  = 7;

    QRectF rect(xOffset,
                conWidth + 20,
                conWidth, conWidth);
    shape.addEllipse(rect);
    //shape.addRect(rect);

    rect = QRectF(m_rect.right() - conWidth - xOffset,
                  conWidth + 20,
                  conWidth, conWidth);
    shape.addEllipse(rect);
    //shape.addRect(rect);
    return shape;
}
开发者ID:RS102839,项目名称:qt,代码行数:25,代码来源:paths.cpp

示例5: shape

QPainterPath SchedulePoint::shape() const
{
    // provide shape of each point
    QRectF rect = outlineRect();
    QPainterPath path;
    path.addRoundRect(rect,roundness(rect.width()), roundness(rect.height()));
    return path;
}
开发者ID:dgerlach,项目名称:Thermostat-Demo,代码行数:8,代码来源:schedulepoint.cpp

示例6: shape

QPainterPath QNodeItem::shape() const
{
   QRectF rect = outlineRect();

   QPainterPath path;
   path.addRoundRect(rect, roundness(rect.width()),
		     roundness(rect.height()));
   return path;
}
开发者ID:petalgem,项目名称:scn,代码行数:9,代码来源:qnetwork.cpp

示例7: paintEvent

void KoContextBarButton::paintEvent(QPaintEvent*)
{
    QStylePainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    QStyleOptionToolButton opt;
    initStyleOption(&opt);

    const QColor bgColor = palette().color(QPalette::Highlight);
    QColor color = bgColor.dark(CONTEXTBAR_BACKGROUND_DARKNESS);
    QColor borderColor = bgColor.light(CONTEXTBAR_BORDER_LIGHTNESS);

    if (opt.state & QStyle::State_MouseOver && opt.state & QStyle::State_Enabled) {
            color = color.light(CONTEXTBAR_MOUSEOVER_LIGHTNESS);
            borderColor = borderColor.lighter(CONTEXTBAR_MOUSEOVER_LIGHTNESS);
    }

    const QRectF rectF = QRectF(opt.rect).adjusted(0.5, 0.5, -0.5, -0.5);
    QPainterPath path;
    path.addRoundRect(rectF, CONTEXTBAR_RADIUS, CONTEXTBAR_RADIUS);

    if (m_fadingValue < 255) {
        color.setAlpha(m_fadingValue);
    }

    // Background
    painter.fillPath(path, color);

    if (opt.state & QStyle::State_Raised && opt.state & QStyle::State_Enabled) {
        // Bottom shadow
        QLinearGradient gradient(rectF.bottomLeft(), rectF.bottomLeft() - QPoint(0, 5));
        gradient.setColorAt(0, QColor::fromHsvF(0, 0, 0, .3));
        gradient.setColorAt(1, Qt::transparent);
        painter.fillPath(path, gradient);

        // Left shadow
        gradient.setFinalStop(rectF.bottomLeft() + QPoint(3, 0));
        painter.fillPath(path, gradient);
    }
    else {
        // Top shadow
        QLinearGradient gradient(rectF.topLeft(), rectF.topLeft() + QPoint(0, 5));
        gradient.setColorAt(0, QColor::fromHsvF(0, 0, 0, .3));
        gradient.setColorAt(1, Qt::transparent);
        painter.fillPath(path, gradient);

        // Left shadow
        gradient.setFinalStop(rectF.topLeft() + QPoint(5, 0));
        painter.fillPath(path, gradient);
    }

    // Border
    painter.setPen(QPen(borderColor, 0));
    painter.drawPath(path);

    // Content
    painter.drawControl(QStyle::CE_ToolButtonLabel, opt);
}
开发者ID:KDE,项目名称:calligra,代码行数:57,代码来源:KoContextBarButton.cpp

示例8: paintEvent

void SelectLocation::paintEvent(QPaintEvent *paintevent)
{
	QPainter painter;
	QPainterPath roundedrect;
	roundedrect.addRoundRect(this->rect(),20);
	
	painter.setOpacity(0.8);
	painter.fillPath(roundedrect,QColor(Qt::black));
	painter.setOpacity(1);
	
}
开发者ID:tvespasian,项目名称:weatherwidget2,代码行数:11,代码来源:SelectLocation.cpp

示例9: backgroundPath

QPainterPath EvButton::backgroundPath() const
{
    QPainterPath path;
    if(m_rounded){
        path.addRoundRect(rect(),roundness());
    }
    else{
        path.addRect(rect());
    }

    return path;
}
开发者ID:kaabimg,项目名称:EvLibrary,代码行数:12,代码来源:EvButton.cpp

示例10: rect

QPainterPath
dmz::QtCanvasObjectText::shape () const {

   QPainterPath path;

   if (_text.length ()) {

      QRectF rect (_outline_rect ());
      path.addRoundRect (rect, _roundness (rect.width ()), _roundness (rect.height ()));
   }

   return path;
}
开发者ID:ben-sangster,项目名称:dmz,代码行数:13,代码来源:dmzQtPluginCanvasObjectBasic.cpp

示例11: paint

  void TOPPASMergerVertex::paint(QPainter * painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
  {
    __DEBUG_BEGIN_METHOD__

    QPen pen(pen_color_, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
    if (isSelected())
    {
      pen.setWidth(2);
      painter->setBrush(brush_color_.darker(130));
      pen.setColor(Qt::darkBlue);
    }
    else
    {
      painter->setBrush(brush_color_);
    }
    painter->setPen(pen);

    QPainterPath path;
    path.addRoundRect(-40.0, -40.0, 80.0, 80.0, 20, 20);
    painter->drawPath(path);

    pen.setColor(pen_color_);
    painter->setPen(pen);

    QString text = round_based_mode_ ? "Merge" : "Collect";
    QRectF text_boundings = painter->boundingRect(QRectF(0, 0, 0, 0), Qt::AlignCenter, text);
    painter->drawText(-(int)(text_boundings.width() / 2.0), (int)(text_boundings.height() / 4.0), text);

    if (round_total_ != -1) // draw round number
    {
      text = QString::number(round_counter_) + " / " + QString::number(round_total_);
      text_boundings = painter->boundingRect(QRectF(0, 0, 0, 0), Qt::AlignCenter, text);
      painter->drawText(-(int)(text_boundings.width() / 2.0), 31, text);
    }

    //topo sort number
    qreal x_pos = -36.0;
    qreal y_pos = -23.0;
    painter->drawText(x_pos, y_pos, QString::number(topo_nr_));


    // recycling status
    if (this->allow_output_recycling_)
    {
      painter->setPen(Qt::green);
      QSvgRenderer * svg_renderer = new QSvgRenderer(QString(":/Recycling_symbol.svg"), 0);
      svg_renderer->render(painter, QRectF(-7, -32, 14, 14));
    }

    __DEBUG_END_METHOD__
  }
开发者ID:BioITer,项目名称:OpenMS,代码行数:51,代码来源:TOPPASMergerVertex.C

示例12: drawBackroundFrame

void ClassicBackgroundRender::drawBackroundFrame(QPainter *painter,
                                                 const QRectF &rect) {
  painter->fillRect(rect, QColor(0, 0, 0));
  painter->save();
  float xoffset = (rect.width() - mBackgroundImage.width()) / 2;
  float yoffset = (rect.height() - mBackgroundImage.height()) / 2;
  QRectF imageRect(xoffset, yoffset, mBackgroundImage.width(),
                   mBackgroundImage.height());
  QPainterPath path;
  path.addRoundRect(imageRect, 8.0, 8.0);
  painter->setClipPath(path);
  painter->drawImage(imageRect, mBackgroundImage);
  painter->restore();
}
开发者ID:shaheeqa,项目名称:plexydesk,代码行数:14,代码来源:classicbackgroundrender.cpp

示例13: textPath

QPainterPath EvButton::textPath() const
{
    QPainterPath path;
    path.setFillRule( Qt::WindingFill);

    QRect rect = textRect();
    if(m_rounded){
        float roundness = this->roundness();
        path.addRoundRect( rect, roundness );
        path.addRect( QRect(rect.x(),0, roundness,roundness ) );
        path.addRect( QRect( rect.x(),rect.y() , roundness,roundness ) );
    }
    else{
        path.addRect(rect);
    }
    return path.simplified();
}
开发者ID:kaabimg,项目名称:EvLibrary,代码行数:17,代码来源:EvButton.cpp

示例14: paintEvent

// Прорисовка обводки виджета
void ToolTip::paintEvent(QPaintEvent *event)
{
    int roundness(3);
    QPainter painter(this);
    painter.save();

    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(Qt::red);

    QPainterPath roundedRect;
    roundedRect.addRoundRect(1, 1, this->rect().width() - 2, this->rect().height() - 2, roundness, roundness);
    painter.setClipPath(roundedRect);

    QRegion maskregion = painter.clipRegion();
    setMask(maskregion);
    painter.setBrush(Qt::NoBrush);
    painter.setPen(QPen(QColor(128, 128, 128), 3, Qt::SolidLine));
    painter.drawRoundedRect(1, 1, this->rect().width() - 2, this->rect().height() - 2, roundness + 2, roundness + 2);
    // restore painter
    painter.restore();

    QWidget::paintEvent(event);
}
开发者ID:alekseymenkov,项目名称:constructor,代码行数:24,代码来源:tooltip.cpp

示例15: paint


//.........这里部分代码省略.........
		itemAlignment = Qt::Alignment(alignValue.toInt());

	int keywordsCount = keywordList.size();
	for (int i=0; i<keywordsCount; ++i)
	{
		lastX = x = option.rect.x()+textHMargin;
		//QString keyword = keywordList.isEmpty() ? "" : keywordList.at(0);
		QString keyword = keywordList.at(i);

		keyword.replace(QChar(0x200C), "", Qt::CaseInsensitive);//replace ZWNJ by ""
		//qDebug() << "keyword1="<<keyword;
		keyword = keyword.split("", QString::SkipEmptyParts).join(tatweel+"*");
		//qDebug() << "keyword2="<<keyword;
		keyword.replace("@"+tatweel+"*", "\\S*", Qt::CaseInsensitive);//replace wildcard by word chars
		//qDebug() << "keyword3="<<keyword;
		QRegExp maybeTatweel(keyword, Qt::CaseInsensitive);
		maybeTatweel.indexIn(text);
		//qDebug() << text<<"count=" << maybeTatweel.captureCount()<<maybeTatweel.capturedTexts();
		//qDebug() << "Match: "<<maybeTatweel.cap(0);
		keyword = maybeTatweel.cap(0);
	if (!(keyword.isEmpty() || text.indexOf(keyword) == -1 ) )
	{
		QString txt = text;
		while (txt.size() > 0)
		{
			int index = txt.indexOf(keyword);
			QString thisPart;
			if (index == -1)
			{
				thisPart = txt;
				txt = QString();
			}
			else
			{
				if (index == 0)
				{
					thisPart = txt.mid(0, keyword.size());
					if (txt == keyword)
						txt = QString();
					else
						txt = txt.mid(keyword.size(), txt.size() - keyword.size());
				}
				else
				{
					thisPart = txt.mid(0, index);
					txt = txt.mid(index);
				}
			}
				
			QSize sz = fontMetric.boundingRect(thisPart).size();
			if (index == 0)
			{
				if (flagRightToLeft)
				{
					switch (itemAlignment^Qt::AlignVCenter)
					{
						case Qt::AlignRight:
							lastX = option.rect.left()+textHMargin+fontMetric.boundingRect(text).width()-(lastX-option.rect.x()+sz.width()-textHMargin);
							break;

						case Qt::AlignHCenter:
							lastX = option.rect.left()+textHMargin+fontMetric.boundingRect(text).width()-(lastX-option.rect.x()+sz.width()-textHMargin)+((option.rect.width()-fontMetric.boundingRect(text).width()-textHMargin)/2);
							break;

						case Qt::AlignLeft:
						default:
							lastX = option.rect.right()+textHMargin-1 - (lastX-option.rect.x()+sz.width());
							break;
					}
				}

				QRectF rectf(lastX , option.rect.y()+((option.rect.height()-qMin(option.rect.height(), fontMetric.height()))/2), sz.width(), fontMetric.height() );
				qreal oldOpacity = painter->opacity();
				painter->setOpacity(0.65);
				rectf.adjust(-iconWidth, 0, -iconWidth, 0);
				QPainterPath roundedRect;
				roundedRect.addRoundRect(rectf, 50, 50);
				QPen defaultPen(painter->pen());
				painter->setPen(SaagharWidget::matchedTextColor.darker(150));
				painter->drawPath(roundedRect);
				painter->fillPath( roundedRect, itemBrush );
				painter->setOpacity(oldOpacity);
				painter->setPen(defaultPen);
				//painter->fillRect( rectf, itemBrush );
			}
			x += option.fontMetrics.width(thisPart);
			lastX = x;
		}
	}
	else if (!(keyword.isEmpty() || cleanedText.indexOf(keyword) == -1 ) )
	{
		qreal oldOpacity = painter->opacity();
		painter->setOpacity(0.35);
		painter->fillRect( option.rect, itemBrush );
		painter->setOpacity(oldOpacity);
		//painter->fillRect( rectf, itemBrush );
	}
	}
	QStyledItemDelegate::paint(painter, option, index);
}
开发者ID:mkhoeini,项目名称:Saaghar2,代码行数:101,代码来源:SearchItemDelegate.cpp


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