zoukankan      html  css  js  c++  java
  • 【原创】paintEvent()函数显示文本

    【代码】

    void MainWindow::paintEvent(QPaintEvent*)

    {

    QPainter p(this);

    QRect r;

    p.setPen(Qt::red);

    p.drawText(20, 80, 120, 20, 0, "Hello World!", &r);

    //

    }

     【结果】

    QPoint 点的位置坐标

    QPoint::QPoint(int xpos, int ypos)

    Constructs a point with the given coordinates (xpos, ypos).

    See also setX() and setY().

    [static] int QPoint::dotProduct(const QPoint &p1, const QPoint &p2)

    示例:

    QPoint p( 3, 7);

    QPoint q(-1, 4);

    int lengthSquared = QPoint::dotProduct(p, q);       // lengthSquared becomes 25

    Returns the dot product of p1 and p2.     返回值,点 p1,p2 的距离

    【拓展阅读】

    1、paintEvent 实现绘制钟表的官方例子   http://blog.csdn.net/ljt350740378/article/details/51611975

    2、PaintEvent 绘制窗体背景图片       http://blog.csdn.net/lcalqf/article/details/50662433

    QPixmap m_pBg;

    m_pBg.load("Demo_bg.png");

    void CDemoWnd::paintEvent(QPaintEvent* pEvent)

    {

    QPainter painter;

    painter.begin(this);

    painter.drawPixmap(rect(),m_pBg);

    painter.end();

    }

  • 相关阅读:
    快速指引(CDH6.3.2)
    gRpc 跨语言调用(NetCore 与 Spring Boot)
    Windows 极简利器
    Jenkins 于Docker 中源配置
    Kettle 问题
    在 Ubuntu 下直接将二进制文件制作成 rpm 包
    麒麟常见问题
    基于jssip的简单封装
    带有handleEvent的eventEmitter
    js集锦
  • 原文地址:https://www.cnblogs.com/hhxxgdd/p/8523692.html
Copyright © 2011-2022 走看看