Results 1 to 4 of 4

Thread: How to implement transparent pencil tool in Qt?

  1. #1
    Join Date
    Aug 2010
    Posts
    7
    Thanks
    8

    Default How to implement transparent pencil tool in Qt?

    I'm currently making a Painter like program. And I want to implement a painting tool, pencil, can draw in transparent color, such as rgb(255,0,0,100).

    I've tried to use QPainter and draw things in a QImage and then draw on a QWidget.

    Using QPainter::drawLine with QWidget::mouseMoveEvent is nice when the color is totally opacity one. However, if I use a transparent color, the point that both belongs to the last line and current line, will drawn twice(see attachment).

    And I also tried using QPainter:drawPath and QPainter::drawLines, but none of them are right for this. They won't double draw the "last point" between two lines, but can't draw twice even when user intend to do so( saying you're drawing "8" and the cross should be drawn twice).

    So, maybe impossible, is there a way to solve this? Implement a basic pencil tool?
    Attached Images Attached Images

  2. #2
    Join Date
    Aug 2010
    Posts
    7
    Thanks
    8

    Default Re: How to implement transparent pencil tool in Qt?

    Nobody knows?

  3. #3
    Join Date
    Jun 2012
    Location
    Paris, France
    Posts
    19
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to implement transparent pencil tool in Qt?

    I certainly don't know for sure, but my guess would be to draw an opaque path in an off-screen buffer, apply alpha correction to it, and then transfer it to the screen.

  4. #4
    Join Date
    Aug 2010
    Posts
    7
    Thanks
    8

    Default Re: How to implement transparent pencil tool in Qt?

    It works if we only draw once. However, any new painted color can't use opaque color to compose with the old painted colors.

Similar Threads

  1. Replies: 1
    Last Post: 28th December 2010, 09:43
  2. How to implement a graphical curve drawing/editing tool
    By hakiim35 in forum Qt Programming
    Replies: 3
    Last Post: 21st December 2010, 21:40
  3. Replies: 0
    Last Post: 25th August 2010, 17:39
  4. Grouping of Tool buttons in Tool bar
    By febil in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2009, 11:51
  5. Transparent background on QLabel on transparent QWidget
    By codeslicer in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2008, 02: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.