程序主要由OneBox、BoxGroup和MyView三个类构成,分别实现了小正方形,方块图形和游戏场景。classOneBox:publicQGraphicsObject{public:OneBox(constQColor&color=Qt::red);QRectFboundingRect()const;voidpaint(QPainter*painter,constQStyleOptionGraphicsItem*option,QW..
分类:
其他好文 时间:
2014-12-16 19:24:38
阅读次数:
166
QPainter painter1(this);//新建类 painter1.setRenderHint(QPainter::Antialiasing,true);//设置反锯齿 painter1.setBrush(QBrush(/*Qt::green,*/ QPixmap(":/qm...
分类:
其他好文 时间:
2014-12-09 21:18:17
阅读次数:
231
tesb::tesb(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
}
void tesb::DrawCustomLine(QPainter& _painter, double _angle, double _len, const QString& _name, const QColor& _color)
{
// 初始化
...
分类:
其他好文 时间:
2014-12-09 12:20:28
阅读次数:
226
之前一直以为 Qt Quick 里 Canvas 才可以自绘,后来发觉不是,原来还有好几种方式都可以绘图!可以使用原始的 OpenGL(Qt Quick 使用 OpenGL 渲染),可以构造QSGNode 来绘图,还可以使用 QPainter !哇, QPainter 我很熟悉啊。于是,我用 QPa...
分类:
其他好文 时间:
2014-11-22 01:57:04
阅读次数:
423
实现自己的Qt Quick元素,使用QPainter绘图……...
分类:
其他好文 时间:
2014-11-21 06:57:36
阅读次数:
273
在Qt中常常要自己重载一些paintEvent函数,这个时候往往忽略了两个很关键的API,那就是setViewport和setWindow。 Viewport,顾名思义,反应的是物理坐标,就是你实际想在当前坐标系下哪块区域画图,比如(50,50,100,100)的一个rect. Window而是逻....
分类:
Windows程序 时间:
2014-10-23 09:23:47
阅读次数:
3384
比如当你Qt中用QPainter进行window和viewport,逻辑和物理坐标分离的形式进行绘图放大的时候,你会发现鼠标的移动和放大之后的图像有点不跟手,比如你是用QTransform进行放大变换,其实这个时候有个小窍门可以比较方便的解决这个 问题就是用反向的QTransform,比如前者进行v...
分类:
其他好文 时间:
2014-10-23 09:21:19
阅读次数:
120
void ShareeSignatureDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { // 沿用父类的绘制效果 QS...
分类:
其他好文 时间:
2014-10-18 15:27:35
阅读次数:
195
void MainWindow::paintEvent(QPaintEvent *)
{
qDebug() << "paintEvent";
QPainter painter(this);
//上半部分背景
QPixmap banner(":/login/banner_5");
banner.setDevicePixelRatio(2...
Qt 内置对OpenGL ES的支持,选用Qt进行OpenGL ES的开发是非常方便的,许多辅助类头已经具备。从Qt 5.0开始增加了一个QWindow类,该类既可以使用OpenGL绘制3D图形,也可以使用QPainter绘制2D传统的GDI+图形,5.0以前的QGLWidget不推荐再使用。在即将到来(官方时间是今年秋天)Qt 5.4会完全废弃QGLWidget,作为替代将会新增QOpenGLW...
分类:
移动开发 时间:
2014-09-03 13:12:26
阅读次数:
419