Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML type to draw with QPainter
Forum Updated to NodeBB v4.3 + New Features

QML type to draw with QPainter

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 3 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alan73
    wrote on last edited by
    #1

    Hello!
    In QML documentation I found an example of custom type (defined from C++) to draw on it with QPainter:

    Header:
    @
    #include <QtQuick/QQuickPaintedItem>

    class PieChart : public QQuickPaintedItem
    {
    ...
    public:
    void paint(QPainter *painter);
    ...
    };@

    Source:

    @void PieChart::paint(QPainter painter)
    {
    QPen pen(m_color, 2);
    painter->setPen(pen);
    painter->setRenderHints(QPainter::Antialiasing, true);
    painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90
    16, 290*16);
    }@

    How can I derive a type to draw (e.g. a line) on it asynchronously with QPainter? Thanks!

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jens
      wrote on last edited by
      #2

      It is not really clear what you mean by asynchronously here. QQuickPainted item is already implicitly painted asynchronously relative to the scenegraph rendering depending on which platform it is running on. Most likely it is exactly what you should be using to draw a line using QPainter. What makes you think it is unsuitable?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aabc
        wrote on last edited by
        #3

        You can use the QPainter or to use openGL API for paint

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved