Doc: Make Qt Gui snippets compilable - brush
Remove unused code in snippet files not referenced from anywhere. Task-number: QTBUG-81486 Change-Id: I80b46c013bde99e1aea86311d3579ccc922b8fd7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>bb10
parent
5bf7ceb4d4
commit
5596344100
|
|
@ -47,50 +47,25 @@
|
|||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include <QLinearGradient>
|
||||
|
||||
#include <QtGui>
|
||||
namespace brush {
|
||||
void wrapper() {
|
||||
|
||||
int main()
|
||||
{
|
||||
QWidget anyPaintDevice;
|
||||
{
|
||||
// PEN SNIPPET
|
||||
QPainter painter;
|
||||
QPen pen(Qt::red, 2); // red solid line, 2 pixels wide
|
||||
painter.begin(&anyPaintDevice); // paint something
|
||||
painter.setPen(pen); // set the red, wide pen
|
||||
painter.drawRect(40,30, 200,100); // draw a rectangle
|
||||
painter.setPen(Qt::blue); // set blue pen, 0 pixel width
|
||||
painter.drawLine(40,30, 240,130); // draw a diagonal in rectangle
|
||||
painter.end(); // painting done
|
||||
}
|
||||
|
||||
{
|
||||
// BRUSH SNIPPET
|
||||
QPainter painter;
|
||||
QBrush brush(Qt::yellow); // yellow solid pattern
|
||||
painter.begin(&anyPaintDevice); // paint something
|
||||
painter.setBrush(brush); // set the yellow brush
|
||||
painter.setPen(Qt::NoPen); // do not draw outline
|
||||
painter.drawRect(40,30, 200,100); // draw filled rectangle
|
||||
painter.setBrush(Qt::NoBrush); // do not fill
|
||||
painter.setPen(Qt::black); // set black pen, 0 pixel width
|
||||
painter.drawRect(10,10, 30,20); // draw rectangle outline
|
||||
painter.end(); // painting done
|
||||
}
|
||||
|
||||
// LINEAR
|
||||
//! [0]
|
||||
QLinearGradient linearGrad(QPointF(100, 100), QPointF(200, 200));
|
||||
linearGrad.setColorAt(0, Qt::black);
|
||||
linearGrad.setColorAt(1, Qt::white);
|
||||
QLinearGradient linearGrad(QPointF(100, 100), QPointF(200, 200));
|
||||
linearGrad.setColorAt(0, Qt::black);
|
||||
linearGrad.setColorAt(1, Qt::white);
|
||||
//! [0]
|
||||
|
||||
// RADIAL
|
||||
|
||||
//! [1]
|
||||
QRadialGradient radialGrad(QPointF(100, 100), 100);
|
||||
radialGrad.setColorAt(0, Qt::red);
|
||||
radialGrad.setColorAt(0.5, Qt::blue);
|
||||
radialGrad.setColorAt(1, Qt::green);
|
||||
QRadialGradient radialGrad(QPointF(100, 100), 100);
|
||||
radialGrad.setColorAt(0, Qt::red);
|
||||
radialGrad.setColorAt(0.5, Qt::blue);
|
||||
radialGrad.setColorAt(1, Qt::green);
|
||||
//! [1]
|
||||
}
|
||||
|
||||
} // wrapper
|
||||
} // brush
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
TEMPLATE = lib
|
||||
TARGET = brush_snippets
|
||||
QT += core gui widgets
|
||||
|
||||
SOURCES = \
|
||||
brush.cpp \
|
||||
gradientcreationsnippet.cpp
|
||||
|
||||
|
|
@ -48,11 +48,11 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtGui>
|
||||
#include <QBrush>
|
||||
|
||||
int main(int argv, char **args)
|
||||
{
|
||||
QApplication app(argv, args);
|
||||
namespace gradientcreationsnippet {
|
||||
|
||||
void wrapper() {
|
||||
|
||||
//! [0]
|
||||
QRadialGradient gradient(50, 50, 50, 50, 50);
|
||||
|
|
@ -62,11 +62,6 @@ int main(int argv, char **args)
|
|||
QBrush brush(gradient);
|
||||
//! [0]
|
||||
|
||||
QWidget widget;
|
||||
QPalette palette;
|
||||
palette.setBrush(widget.backgroundRole(), brush);
|
||||
widget.setPalette(palette);
|
||||
widget.show();
|
||||
} // wrapper
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
} // gradientcreationsnippet
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ SUBDIRS =
|
|||
|
||||
contains(QT_BUILD_PARTS, tests) {
|
||||
SUBDIRS += \
|
||||
brush \
|
||||
code \
|
||||
qfontdatabase \
|
||||
textdocument-end
|
||||
|
|
|
|||
Loading…
Reference in New Issue