Results 1 to 4 of 4

Thread: How do I paint directly ina QGraphcicsView?

  1. #1
    Join Date
    Jun 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default How do I paint directly ina QGraphcicsView?

    I am doing a drawing application, and the idea of adding a new line to a QGraphicsScene just to allow the users to draw a line from point A to point B looks unnecessarily contrived. Is it possible for me to overload QGraphicsView::paintEvent() and to get a QPainter there? I have tried, but it is not working.

    Any advice would be welcomed.

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

    Default Re: How do I paint directly ina QGraphcicsView?

    Add the line normally Alternatively use [wiki]Widget Overlay[/wiki] but it's probably better to add the line to the scene,
    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.


  3. #3
    Join Date
    Jun 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How do I paint directly ina QGraphcicsView?

    I guess I am going with this solution for now. I mean, I could just draw the line in the view (just for the drag and dropping of line) and emit a signal one the mouseReleased event, which I think is a lot simpler than the example (Diagram Example) used in QT.

    Thanks for your answer anyway

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

    Default Re: How do I paint directly ina QGraphcicsView?

    But why would you want to draw an extraordinary line in the view?
    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.


Similar Threads

  1. Drawing standard widgets using a custom paint engine
    By Waywocket in forum Qt Programming
    Replies: 26
    Last Post: 21st October 2010, 20:40
  2. Drawing a widget in QItemDelegate's paint method
    By darkadept in forum Qt Programming
    Replies: 17
    Last Post: 11th August 2009, 05:15
  3. problem with paint and erase in frame
    By M.A.M in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2008, 20:17
  4. cairo4qt 0.9 - a cairo based paint engine for Qt4
    By dragchan in forum Qt-based Software
    Replies: 0
    Last Post: 18th May 2007, 05:07
  5. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 14:24

Tags for this Thread

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.