本文整理汇总了C++中QColor::setAlphaF方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::setAlphaF方法的具体用法?C++ QColor::setAlphaF怎么用?C++ QColor::setAlphaF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::setAlphaF方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateColors
void UserWidget::updateColors()
{
QPalette p = palette();
// Set background to transparent and use the theme to provide contrast with the text
p.setColor(QPalette::Base, Qt::transparent); // new in Qt 4.5
p.setColor(QPalette::Window, Qt::transparent); // For Qt 4.4, remove when we depend on 4.5
QColor text = Theme::defaultTheme()->color(Theme::TextColor);
QColor link = Theme::defaultTheme()->color(Theme::TextColor);
link.setAlphaF(qreal(.8));
QColor linkvisited = Theme::defaultTheme()->color(Theme::TextColor);
linkvisited.setAlphaF(qreal(.6));
p.setColor(QPalette::Text, text);
p.setColor(QPalette::Link, link);
p.setColor(QPalette::LinkVisited, linkvisited);
setPalette(p);
if (m_nameLabel) {
m_nameLabel->setPalette(p);
if (m_css) {
m_nameLabel->setStyleSheet(m_css->styleSheet());
}
m_infoView->page()->setPalette(p);
}
update();
// kDebug() << "CSS:" << m_css->styleSheet();
}
示例2: determineColor
QColor Viewport::determineColor(const QColor &basecolor,
float weight, float totalweight,
bool highlighted, bool single)
{
QColor color = basecolor;
qreal alpha;
/* TODO: this is far from optimal yet. challenge is to give a good
view where important information is not lost, yet not clutter
the view with too much low-weight information */
/* logarithm is used to prevent single data points to get lost.
this should be configurable. */
alpha = useralpha;
if (drawLog->isChecked())
alpha *= (0.01 + 0.99*(std::log(weight+1) / std::log(totalweight)));
else
alpha *= (0.01 + 0.99*(weight / totalweight));
color.setAlphaF(std::min(alpha, 1.)); // cap at 1
if (highlighted) {
if (basecolor == Qt::white) {
color = Qt::yellow;
} else {
color.setGreen(std::min(color.green() + 195, 255));
color.setRed(std::min(color.red() + 195, 255));
color.setBlue(color.blue()/2);
}
color.setAlphaF(1.);
}
// recolor singleLabel (and make 100% opaque)
if (single) {
color.setRgbF(1., 1., 0., 1.);
}
return color;
}
示例3: paintEvent
void VariableEditor::paintEvent(QPaintEvent* event)
{
QWidget::paintEvent(event);
// draw highlighting rect like in plasma
if (underMouse()) {
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QColor cornerColor = palette().color(QPalette::Highlight);
cornerColor.setAlphaF(0.2);
QColor midColor = palette().color(QPalette::Highlight);
midColor.setAlphaF(0.5);
QRect highlightRect = rect().adjusted(2, 2, -2, -2);
QPen outlinePen;
outlinePen.setWidth(2);
QLinearGradient gradient(highlightRect.topLeft(), highlightRect.topRight());
gradient.setColorAt(0, cornerColor);
gradient.setColorAt(0.3, midColor);
gradient.setColorAt(1, cornerColor);
outlinePen.setBrush(gradient);
painter.setPen(outlinePen);
const int radius = 5;
painter.drawRoundedRect(highlightRect, radius, radius);
}
}
示例4: transparency_slider_changed
void Layer_list_model::transparency_slider_changed(int) {
if (l == 0) return;
QColor color = l->get_color();
color.setAlphaF(transparency_slider->value_to_float());
l->set_color(color);
//std::cout << "Color set with transparency: " << transparency_slider->value_to_float() << std::endl;
QColor ambient = l->get_ambient();
ambient.setAlphaF(transparency_slider->value_to_float());
QColor diffuse = l->get_diffuse();
l->set_diffuse(diffuse);
diffuse.setAlphaF(transparency_slider->value_to_float());
QColor specular = l->get_specular();
l->set_specular(specular);
specular.setAlphaF(transparency_slider->value_to_float());
QColor emission = l->get_emission();
emission.setAlphaF(transparency_slider->value_to_float());
l->set_emission(emission);
#ifdef INVALIDATE_CACHE_AT_COLOR_CHANGE
l->invalidate_cache(); /// \todo why do I need this for colors? it should work without invalidating with the display lists
#endif
if (l->has_property(Managable_layer::SCALAR_EDITABLE)) {
l->invalidate_cache();
l->has_new_range = false;
}
emit widget_needs_repaint();
}
示例5: boundingRect
void
Context::Applet::addGradientToAppletBackground( QPainter* p )
{
// tint the whole applet
// draw non-gradient backround. going for elegance and style
const QRectF roundRect = boundingRect().adjusted( 0, 1, -1, -1 );
p->save();
p->setRenderHint( QPainter::Antialiasing );
QPainterPath path;
path.addRoundedRect( roundRect, 4, 4 );
QColor highlight = PaletteHandler::highlightColor( 0.4, 1.05 );
highlight.setAlphaF( highlight.alphaF() * 0.5 );
p->fillPath( path, highlight );
p->restore();
p->save();
p->setRenderHint( QPainter::Antialiasing );
p->translate( 0.5, 0.5 );
QColor col = PaletteHandler::highlightColor( 0.3, 0.5 );
col.setAlphaF( col.alphaF() * 0.7 );
p->setPen( col );
p->drawRoundedRect( roundRect, 4, 4 );
p->restore();
}
示例6: paintEvent
void RatingComboBoxWidget::paintEvent(QPaintEvent* e)
{
if (m_value >= RatingComboBox::Rating0)
{
//kDebug() << "m_value" << m_value << "defaulting paint to parent" << this;
RatingWidget::paintEvent(e);
}
else if (m_value == RatingComboBox::NoRating)
{
QPainter p(this);
QPixmap pix = starPixmap();
int width = pix.width();
p.drawPixmap(0, 0, pix);
// draw red cross
p.setPen(Qt::red);
p.drawLine(0, 0, width, width);
p.drawLine(0, width, width, 0);
}
else if (m_value == RatingComboBox::Null)
{
QPainter p(this);
if (underMouse() && isEnabled())
{
QPixmap pix = starPixmap();
int x = 0;
for (int i = 0; i < RatingMax; ++i)
{
p.drawPixmap(x, 0, pix);
x += pix.width();
}
}
else
{
p.setRenderHint(QPainter::Antialiasing, true);
//pen.setJoinStyle(Qt::MiterJoin);
QColor foreground = palette().color(QPalette::Active, QPalette::Foreground);
QColor background = palette().color(QPalette::Active, QPalette::Background);
foreground.setAlphaF(foreground.alphaF() * 0.5);
background.setAlphaF(background.alphaF() * 0.5);
QColor foregroundEnd(foreground), backgroundEnd(background);
foregroundEnd.setAlphaF(0);
backgroundEnd.setAlphaF(0);
QLinearGradient grad(QPointF(0, (double)rect().height() / 2), QPointF(width(), (double)rect().height() / 2));
grad.setColorAt(0, foreground);
grad.setColorAt(1, foregroundEnd);
p.setPen(QPen(grad, 0));
grad.setColorAt(0, background);
grad.setColorAt(1, backgroundEnd);
p.setBrush(grad);
drawStarPolygons(&p, 5);
}
}
}
示例7:
void QgsSimpleLineSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
QColor penColor = mColor;
penColor.setAlphaF( context.alpha() );
mPen.setColor( penColor );
double scaledWidth = context.outputLineWidth( mWidth );
mPen.setWidthF( scaledWidth );
if ( mUseCustomDashPattern && scaledWidth != 0 )
{
mPen.setStyle( Qt::CustomDashLine );
//scale pattern vector
QVector<qreal> scaledVector;
QVector<qreal>::const_iterator it = mCustomDashVector.constBegin();
for ( ; it != mCustomDashVector.constEnd(); ++it )
{
//the dash is specified in terms of pen widths, therefore the division
scaledVector << context.outputLineWidth(( *it ) / scaledWidth );
}
mPen.setDashPattern( scaledVector );
}
else
{
mPen.setStyle( mPenStyle );
}
mPen.setJoinStyle( mPenJoinStyle );
mPen.setCapStyle( mPenCapStyle );
mSelPen = mPen;
QColor selColor = context.selectionColor();
if ( ! selectionIsOpaque )
selColor.setAlphaF( context.alpha() );
mSelPen.setColor( selColor );
}
示例8: generateImage
void WaveformMarkRange::generateImage(int weidth, int height) {
m_activeImage = QImage(weidth, height, QImage::Format_ARGB32_Premultiplied);
m_disabledImage = QImage(weidth, height, QImage::Format_ARGB32_Premultiplied);
// fill needed cause they remain transparent
m_activeImage.fill(QColor(0,0,0,0).rgba());
m_disabledImage.fill(QColor(0,0,0,0).rgba());
QColor activeColor = m_activeColor;
activeColor.setAlphaF(0.3);
QBrush brush(activeColor);
QPainter painter;
painter.begin(&m_activeImage);
painter.fillRect(m_activeImage.rect(), brush);
painter.end();
QColor disabledColor = m_disabledColor;
disabledColor.setAlphaF(0.3);
brush = QBrush(disabledColor);
painter.begin(&m_disabledImage);
painter.fillRect(m_disabledImage.rect(), brush);
painter.end();
}
示例9: toColor
QColor ColorRangeBase::toColor(const QVariant &v, ColorRangeBase::ColorModel colormodel)
{
if ( v.type() == QVariant::Color)
return QColor(v.value<QColor>());
else if ( v.type() == QVariant::String){
QRegExp separ("[(]|,|[)]");
QStringList parts = (v.toString()).split(separ);
if(parts.last().isEmpty())
parts.removeLast();
QColor clr;
bool ok1,ok2,ok3,ok4,ok5 =true;
if ( parts.size() >= 5){
double component1 = parts[1].toDouble(&ok1);
double component2 = parts[2].toDouble(&ok2);
double component3 = parts[3].toDouble(&ok3);
double component4 = parts[4].toDouble(&ok4);
double component5 = parts.size()== 6 ? parts[5].toDouble(&ok5) : rUNDEF;
if(! (ok1 && ok2 && ok3 && ok4 && ok5))
return QColor();
bool isFractional = component1 <= 1 && component2 <= 1 && component3 <= 1 && component4 <= 1;
if ( parts[0].toLower() == "rgba"){
if ( isFractional){
clr.setRgbF(component1,component2, component3);
clr.setAlphaF(component4);
}
else{
clr.setRgb(component1,component2, component3);
clr.setAlpha(component4);
}
}else if ( parts[0].toLower() == "hsla"){
if ( isFractional){
clr.setHslF(component1,component2, component3);
clr.setAlphaF(component4);
}
else{
clr.setHsl(component1,component2, component3);
clr.setAlpha(component4);
}
} else if ( parts[0].toLower() == "cmyka" && parts.size() == 6){
if ( isFractional){
clr.setCmykF(component1,component2, component3, component4);
clr.setAlphaF(component5);
}
else{
clr.setCmyk(component1,component2, component3, component4);
clr.setAlpha(component5);
}
}
return clr;
}
} else if( v.type() == QVariant::ULongLong){
return ColorRangeBase::toColor(v.toULongLong(),colormodel);
} else if( v.type() == QVariant::Double){
return ColorRangeBase::toColor(v.toULongLong(),colormodel);
}
return QColor();
}
示例10: pos
SelectionDrawer::SelectionDrawer(DrawerInterface *parentDrawer, RootDrawer *rootdrawer, const IOOptions &options) : SimpleDrawer("SelectionDrawer", parentDrawer,rootdrawer, options)
{
_vertexShader = "featurevertexshader_nvdia.glsl";
_fragmentShader = "featurefragmentshader_nvdia.glsl";
QColor clr;
_colors.resize(13);
if ( options.contains("areacolor")){
clr = options["areacolor"].value<QColor>();
}else {
clr = QColor(80,80,0);
clr.setAlphaF(0.15);
}
_colors[9] = _colors[10] = _colors[11] = _colors[12] = clr;
clr.setAlphaF(0.5);
_colors[5] = _colors[6] = _colors[7] = _colors[8] = clr;
if ( options.contains("bordercolor")){
clr = options["bordercolor"].value<QColor>();
}else {
clr = QColor(0,0,0);
clr.setAlphaF(1);
}
_colors[0] = _colors[1] = _colors[2] = _colors[3] = _colors[4] = clr;
QVector3D pos(0,0,0);
_vertices = { pos,pos,pos,pos,pos, pos,pos,pos,pos, pos,pos,pos,pos};
_indices.push_back(VertexIndex(0, 5, itLINE, iUNDEF));
_indices.push_back(VertexIndex(5, 2, itLINE, iUNDEF));
_indices.push_back(VertexIndex(7, 2, itLINE, iUNDEF));
_indices.push_back(VertexIndex(9, 4, itPOLYGON, iUNDEF));
}
示例11: updatePreview
void QgsLabelingGui::updatePreview()
{
scrollPreview();
lblFontPreview->setFont( mRefFont );
QFont previewFont = lblFontPreview->font();
if ( mFontSizeUnitComboBox->currentIndex() == 1 )
{
// TODO: maybe match current map zoom level instead?
previewFont.setPointSize( 24 );
groupBox_mPreview->setTitle( tr( "Sample @ 24 pts (using map units)" ) );
}
else
{
previewFont.setPointSize( mFontSizeSpinBox->value() );
groupBox_mPreview->setTitle( tr( "Sample" ) );
}
lblFontPreview->setFont( previewFont );
QColor prevColor = btnTextColor->color();
prevColor.setAlphaF(( 100.0 - ( double )( mFontTranspSpinBox->value() ) ) / 100.0 );
lblFontPreview->setTextColor( prevColor );
if ( chkBuffer->isChecked() )
{
QColor buffColor = btnBufferColor->color();
buffColor.setAlphaF(( 100.0 - ( double )( mBufferTranspSpinBox->value() ) ) / 100.0 );
lblFontPreview->setBuffer( spinBufferSize->value(), buffColor );
}
else
{
lblFontPreview->setBuffer( 0, Qt::white );
}
}
示例12: QBrush
void QgsSimpleFillSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
QColor fillColor = mColor;
fillColor.setAlphaF( context.alpha() * mColor.alphaF() );
mBrush = QBrush( fillColor, mBrushStyle );
// scale brush content for printout
double rasterScaleFactor = context.renderContext().rasterScaleFactor();
if ( rasterScaleFactor != 1.0 )
{
mBrush.setMatrix( QMatrix().scale( 1.0 / rasterScaleFactor, 1.0 / rasterScaleFactor ) );
}
QColor selColor = context.selectionColor();
QColor selPenColor = selColor == mColor ? selColor : mBorderColor;
if ( ! selectionIsOpaque ) selColor.setAlphaF( context.alpha() );
mSelBrush = QBrush( selColor );
// N.B. unless a "selection line color" is implemented in addition to the "selection color" option
// this would mean symbols with "no fill" look the same whether or not they are selected
if ( selectFillStyle )
mSelBrush.setStyle( mBrushStyle );
QColor borderColor = mBorderColor;
borderColor.setAlphaF( context.alpha() * mBorderColor.alphaF() );
mPen = QPen( borderColor );
mSelPen = QPen( selPenColor );
mPen.setStyle( mBorderStyle );
mPen.setWidthF( context.outputLineWidth( mBorderWidth ) );
}
示例13: draw
void BurstShot::draw(QPainter *painter)
{
painter->save();
QColor whiteBeam(0,255,255,255);
QColor blackBeam(255,0,0,255);
QColor *currentColor = polarity == WHITE? &whiteBeam: &blackBeam;
currentColor->setAlphaF(0.25f);
QPen pen(*currentColor, 15, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
painter->setPen(pen);
drawLines(painter, 15);
currentColor->setAlphaF(0.5f);
pen.setColor(*currentColor);
pen.setWidth(4);
painter->setPen(pen);
drawLines(painter, 10);
pen.setColor(polarity == WHITE? Qt::white : Qt::black);
pen.setWidth(2);
painter->setPen(pen);
drawLines(painter, 5);
//debug
// pen.setColor(Qt::green);
// painter->setPen(pen);
// painter->drawRect(hitBox);
painter->restore();
}
示例14: updateSvgParamGui
void QgsComposerPictureWidget::updateSvgParamGui( bool resetValues )
{
if ( !mPicture )
return;
QString picturePath = mPicture->picturePath();
if ( !picturePath.endsWith( QLatin1String( ".svg" ), Qt::CaseInsensitive ) )
{
mFillColorButton->setEnabled( false );
mStrokeColorButton->setEnabled( false );
mStrokeWidthSpinBox->setEnabled( false );
return;
}
//activate gui for svg parameters only if supported by the svg file
bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
QColor defaultFill, defaultStroke;
double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
QgsApplication::svgCache()->containsParams( picturePath, hasFillParam, hasDefaultFillColor, defaultFill,
hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
if ( resetValues )
{
QColor fill = mFillColorButton->color();
double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
if ( hasDefaultFillColor )
{
fill = defaultFill;
}
fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
mFillColorButton->setColor( fill );
}
mFillColorButton->setEnabled( hasFillParam );
mFillColorButton->setAllowOpacity( hasFillOpacityParam );
if ( resetValues )
{
QColor stroke = mStrokeColorButton->color();
double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
if ( hasDefaultStrokeColor )
{
stroke = defaultStroke;
}
stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
mStrokeColorButton->setColor( stroke );
}
mStrokeColorButton->setEnabled( hasStrokeParam );
mStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
if ( hasDefaultStrokeWidth && resetValues )
{
mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
}
mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
}
示例15: onSetup
void QtWaveformRendererSimpleSignal::onSetup(const QDomNode &node){
Q_UNUSED(node);
QColor borderColor = m_pColors->getSignalColor().lighter(125);
borderColor.setAlphaF(0.5);
m_borderPen.setColor(borderColor);
m_borderPen.setWidthF(1.25);
QColor signalColor = m_pColors->getSignalColor();
signalColor.setAlphaF(0.8);
m_brush = QBrush(signalColor);
}