QWidget Semi-transparent Background Color/bg: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
AutoSpider (talk | contribs) m (AutoSpider moved page QWidget Semi-transparent Background Color Bulgarian to QWidget Semi-transparent Background Color/bg: Localisation) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:snippets]] | {{Cleanup | reason=Auto-imported from ExpressionEngine.}} | ||
[[Category:snippets]] | |||
[[Category:HowTo]] | |||
'''Български''' [[QWidget_Semi-transparent_Background_Color|English]] | '''Български''' [[QWidget_Semi-transparent_Background_Color|English]] | ||
Line 5: | Line 8: | ||
= Полупрозрачен цвят на фона на QWidget = | = Полупрозрачен цвят на фона на QWidget = | ||
Този отрязйк от програмен код показва как са се постигне прозрачност на цвета на фона на | Този отрязйк от програмен код показва как са се постигне прозрачност на цвета на фона на [http://doc.qt.io/qt-5.0/qtwidgets/qwidget.html QWidget] чрез предефиниране на [http://doc.qt.io/qt-5.0/qtwidgets/qwidget.html#paintEvent paintEvent()]. | ||
* Предефиниране на paintEvent | * Предефиниране на paintEvent | ||
.h файл | .h файл | ||
<code> | |||
protected: | |||
//overload from QWidget | //overload from QWidget | ||
void paintEvent(QPaintEvent* event); | |||
</code> | |||
* Имплементиране на paintEvent | * Имплементиране на paintEvent | ||
.cpp файл | .cpp файл | ||
<code> | |||
void MyWidget::paintEvent(QPaintEvent* /*event*/) | |||
{ | |||
QColor backgroundColor = palette().light().color(); | |||
backgroundColor.setAlpha(200); | |||
QPainter customPainter(this); | |||
customPainter.fillRect(rect(),backgroundColor); | |||
} | |||
</code> | |||
Този отрязък от код е вдъхновен от предложеното решение от '''Antonio Di Monaco''' в | Този отрязък от код е вдъхновен от предложеното решение от '''Antonio Di Monaco''' в [http://developer.qt.nokia.com/forums/viewthread/1488 тази тема във форума]. | ||
== Вижте също == | == Вижте също == | ||
[http://developer.qt.nokia.com/wiki/How_to_Change_the_Background_Color_of_QWidget_Bulgarian Как се сменя цвета на фона на QWidget] |
Latest revision as of 16:02, 16 March 2015
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine. Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean. |
Български English
Полупрозрачен цвят на фона на QWidget
Този отрязйк от програмен код показва как са се постигне прозрачност на цвета на фона на QWidget чрез предефиниране на paintEvent().
- Предефиниране на paintEvent
.h файл
protected:
//overload from QWidget
void paintEvent(QPaintEvent* event);
- Имплементиране на paintEvent
.cpp файл
void MyWidget::paintEvent(QPaintEvent* /*event*/)
{
QColor backgroundColor = palette().light().color();
backgroundColor.setAlpha(200);
QPainter customPainter(this);
customPainter.fillRect(rect(),backgroundColor);
}
Този отрязък от код е вдъхновен от предложеното решение от Antonio Di Monaco в тази тема във форума.