Results 1 to 9 of 9

Thread: Custom C++-based QML components in Qt 5?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Custom C++-based QML components in Qt 5?

    Quote Originally Posted by fonzi337 View Post
    The documentation for QQuickItem does not list a virtual paint method as QDeclarativeItem does.
    There exists a virtual paint() method in QQuickPaintedItem.

    If someone could describe what the overall process is for developing C++-based visual QML components in Qt 5 (and, even better, provide a trivial code example) I'd greatly appreciate it.
    From what I see in general one reimplements QQuickItem::updatePaintNode().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Oct 2011
    Posts
    35
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanked 9 Times in 3 Posts

    Default Re: Custom C++-based QML components in Qt 5?

    Thanks wysota. It looks like the documentation for updatePaintNode was updated with a code snippet that clarifies things. Unfortunately, the API for drawing in the Scenegraph seems a little less user-friendly than the QPainter API (for instance, the code snippet under http://doc-snapshot.qt-project.org/5...metrynode.html that shows how to draw a straight line is fairly involved). Hopefully the Scenegraph API will grow to include facilities to simplify these common operations (or perhaps they are available but just haven't been documented yet).

  3. #3
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 74 Times in 54 Posts

    Default Re: Custom C++-based QML components in Qt 5?

    Wait.. that ugly code snippet is just to draw a red line? WTF? If that's how you draw a single red line, what the hell does a real world functional item look like? I fully understand the limitations of a sequential rasterized paint system, but this stuff looks makes it seem Nokia is intentionally making C++ use more difficult.

    For perspective, here's how you draw a red line in traditional QPainter:

    painter->setPen(Qt::red);
    painter->drawLine(0, 0, width(), height());

  4. #4
    Join Date
    Oct 2011
    Posts
    35
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanked 9 Times in 3 Posts

    Default Re: Custom C++-based QML components in Qt 5?

    Yeah, the API seems quite low-level (closer to OpenGL than high-level C++). Is it possible the QSGGeometryNode class is the wrong class to be looking at? I find it hard to believe that the highest-level drawing API provided for Qt 5 is what's found in QSGGeometryNode, but I haven't been able to find anything else so far.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Custom C++-based QML components in Qt 5?

    I'm sure we'll get QPainter API too, probably with a warning that this causes slowdowns compared to scene graph approach.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Oct 2011
    Posts
    35
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanked 9 Times in 3 Posts

    Default Re: Custom C++-based QML components in Qt 5?

    In case anyone else is interested in this, I have found two small tutorials that show concrete examples of how custom C++-based elements are exposed to Qt Quick in Qt 5.

    http://doc-snapshot.qt-project.org/5...mgeometry.html
    http://wiki.qtlabs.org.br/projects/q...les/scenegraph

    These examples are unfortunately still pretty basic/simple, but they at least show the basics.

  7. #7
    Join Date
    Aug 2013
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Custom C++-based QML components in Qt 5?

    Quote Originally Posted by fonzi337 View Post
    In case anyone else is interested in this, I have found two small tutorials that show concrete examples of how custom C++-based elements are exposed to Qt Quick in Qt 5.

    http://doc-snapshot.qt-project.org/5...mgeometry.html
    http://wiki.qtlabs.org.br/projects/q...les/scenegraph
    The Qt documentation erasure fairy strikes again. Both links are now dead.

Similar Threads

  1. Replies: 2
    Last Post: 27th July 2011, 15:49
  2. Linker error when creating custom Property Browser components
    By stefanadelbert in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2010, 03:50
  3. Replies: 2
    Last Post: 30th July 2009, 04:58
  4. Custom Style based on Cleanlooks
    By Tux-Slack in forum Qt Programming
    Replies: 4
    Last Post: 21st September 2007, 10:22
  5. Replies: 1
    Last Post: 26th January 2007, 07:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.