zoukankan      html  css  js  c++  java
  • Qt Learning notes

    Qt Learning notes

    Qt Learning notes

    Draw Images in Qt

    paint system

    https://qt-project.org/doc/qt-4.7/paintsystem.html#id-dfb6c752-0d75-4b13-8270-659d558a3ae7

    QPainter is used to perform drawing operations, QPaintDevice is an abstraction of a two-dimensional space that can be painted on using a QPainter, and QPaintEngine provides the interface that the painter uses to draw onto different types of devices. The QPaintEngine class is used internally by QPainter and QPaintDevice, and is hidden from application programmers unless they create their own device type.

    https://qt-project.org/doc/qt-4.7/images/paintsystem-core.png

    QPainter

    QPainter provides highly optimized functions to do most of the drawing GUI programs require. It can draw everything from simple lines to complex shapes like pies and chords. It can also draw aligned text and pixmaps. Normally, it draws in a "natural" coordinate system, but it can also do view and world transformation. QPainter can operate on any object that inherits the QPaintDevice class.

    The common use of QPainter is inside a widget's paint event: Construct and customize (e.g. set the pen or the brush) the painter. Then draw. Remember to destroy the QPainter object after drawing. For example:

    void SimpleExampleWidget::paintEvent(QPaintEvent *)
     {
        QPainter painter(this);
        painter.setPen(Qt::blue);
        painter.setFont(QFont("Arial", 30));
        painter.drawText(rect(), Qt::AlignCenter, "Qt");
    }
    

    The core functionality of QPainter is drawing, but the class also provide several functions that allows you to customize QPainter's settings and its rendering quality, and others that enable clipping. In addition you can control how different shapes are merged together by specifying the painter's composition mode.

    Coordinate System

    https://qt-project.org/doc/qt-4.7/coordsys.html#id-453ffa45-ef2c-4360-8538-c4aa5e3790fe

    The QPaintDevice class is the base class of objects that can be painted: Its drawing capabilities are inherited by the QWidget, QPixmap, QPicture, QImage, and QPrinter classes. The default coordinate system of a paint device has its origin at the top-left corner. The x values increase to the right and the y values increase downwards. The default unit is one pixel on pixel-based devices and one point (1/72 of an inch) on printers.

    Anti-aliased Painting

    https://qt-project.org/doc/qt-4.7/images/coordinatesystem-rect-antialias.png

    QPainter painter(this);
    painter.setRenderHint(
        QPainter::Antialiasing);
    painter.setPen(Qt::darkGreen);
    painter.drawRect(1, 2, 6, 4);
    

    Note

    Qt is an open-source project, the source code is available at http://qt.gitorious.org/.


    Post by: Jalen Wang (转载请注明出处)

  • 相关阅读:
    S2-052 RCE漏洞 初步分析
    Struts S2-048 RCE漏洞分析
    CSP-S2019游记
    委托学习笔记1:委托的基本使用
    jQuery无刷新上传学习心得
    Nuget-自定义模板的创建与使用
    DotNetCore笔记-nginx代理访问swagger
    SQLServer中Partition By 函数的使用
    IE11 Windows7下F12 DOC资源管理器不能用Exception in window.onload: Error: An error has ocurredJSPlugin.3005
    Angular-ui-router入门
  • 原文地址:https://www.cnblogs.com/jalenwang/p/3010181.html
Copyright © 2011-2022 走看看