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

    }

  • 相关阅读:
    Comet OJ
    Comet OJ
    Comet OJ
    Comet OJ
    Codeforces Round #562 (Div. 2)
    P1202 USACO1.1 黑色星期五
    P1201 USACO1.1 贪婪的送礼者
    【线段树】HDU1166:敌兵布阵
    标准C++中的string类的用法总结(转)
    【递归】分形
  • 原文地址:https://www.cnblogs.com/hhxxgdd/p/8523692.html
Copyright © 2011-2022 走看看