Results 1 to 3 of 3

Thread: Drawing shapes

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Drawing shapes

    Hi,

    How can I use the mouse to draw shapes? I want to draw Rectangular, Circular, Elliptic and Irregular shapes. For Rectangular, Circular and Elliptic shapes I'd like to make them resizable by using square corners. The Irregular shape have to be painted by clicking the mouse and moving the pointer, when releasing the mouse it will have to close the shape.

    I'm tinking on using QGraphicsView with every shape as QGraphicsItem but I don't know how to implement the resizing code.

    Another question: I have a QScrollArea with a internal QWidget. Can the QScrollArea or the QWidget be used as viewport of the QGraphicsView?

    Thanks,
    Last edited by ^NyAw^; 30th October 2008 at 12:48.
    Òscar Llarch i Galán

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Drawing shapes

    Quote Originally Posted by ^NyAw^ View Post
    How can I use the mouse to draw shapes? I want to draw Rectangular, Circular, Elliptic and Irregular shapes. For Rectangular, Circular and Elliptic shapes I'd like to make them resizable by using square corners. The Irregular shape have to be painted by clicking the mouse and moving the pointer, when releasing the mouse it will have to close the shape.

    I'm tinking on using QGraphicsView with every shape as QGraphicsItem but I don't know how to implement the resizing code.
    Sounds like a perfect candidate for the graphics view framework. The resizing functionality is something that needs to be written by hand.

    Another question: I have a QScrollArea with a internal QWidget. Can the QScrollArea or the QWidget be used as viewport of the QGraphicsView?
    Sorry, I don't follow. What would be the benefit of that? QGraphicsView is already a QAbstractScrollArea.
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Drawing shapes

    Hi,

    Sorry, I don't follow. What would be the benefit of that? QGraphicsView is already a QAbstractScrollArea.
    I didn't know. . Just because now I'm using a QScrollArea and an internal QWidget.

    Is there any example or similar code of resizing the items?

    And, the Irregular shape, any idea how to do it?

    Thanks,
    Òscar Llarch i Galán

Similar Threads

  1. [SOLVED] QTreeView drawing selection with icons
    By Timewarp in forum Qt Programming
    Replies: 7
    Last Post: 7th February 2013, 07:52
  2. Problems with QString
    By cyberboy in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2008, 08:18
  3. Drawing speed: QPixmap vs QPicture
    By maverick_pol in forum Qt Programming
    Replies: 1
    Last Post: 2nd January 2008, 19:17
  4. Drawing on QWidget - strech & resize
    By kemp in forum Qt Programming
    Replies: 5
    Last Post: 22nd January 2007, 14:39
  5. Drawing using QT
    By Kapil in forum Newbie
    Replies: 1
    Last Post: 17th March 2006, 04:23

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.