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();

    }

  • 相关阅读:
    ubuntu 更新软件
    如何在linux(lubuntu)下搭建C/C++开发环境
    Linux下如何查看版本信息
    知识点笔记
    Require.js中使用jQuery 插件
    async中常用总结
    node.js在遇到“循环+异步”时的注意事项
    前端性能优化
    生产/消费者问题
    线程与内存
  • 原文地址:https://www.cnblogs.com/hhxxgdd/p/8523692.html
Copyright © 2011-2022 走看看