Results 1 to 2 of 2

Thread: Create own widget with graphics items - best way.

  1. #1
    Join Date
    Feb 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Create own widget with graphics items - best way.

    Hi,
    I try to create widget which will represent checkers board. Widget should be resizable so all images(checkers, board) will be in svg format.
    Which way to implement that is proper:
    1. Inherits QGraphicsView. Set board, and checkers as QGraphicsSvgItems. Use fitInView to show the whole board.
    2. Inherits QSvgWidget. Load board... and how can I place checkers on my board?
    3. Inherits QWidget and try to paint on it(I don't know how already).

    Are there another solutions?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Create own widget with graphics items - best way.

    Are there another solutions?
    Sure, one of them is to use QGLWidget and do all the painting in OpenGL.
    Inherits QWidget and try to paint on it(I don't know how already).
    I think it's not really good way to go here. You want to simply draw few items and I assume be able to interact with them ( move ). My choice here would be option 1, because you'll have all basic functionallity already implemented - you have all the power of graphics items and scene events (mouse, keyboard, hovers) ready to be used.
    Other solutions ( including mine ) will require lot more coding.
    --------------------
    One more thing - I'd rather subclass QGraphicsScene than QGraphicsView (or probably both ), view is just for displaying the content of your scene.
    Last edited by stampede; 25th February 2011 at 21:01. Reason: updated contents

Similar Threads

  1. display graphics items on area
    By quantum.17 in forum Qt Programming
    Replies: 0
    Last Post: 5th May 2010, 11:19
  2. Graphics view with millions of items
    By JovianGhost in forum Qt Programming
    Replies: 13
    Last Post: 26th March 2010, 23:58
  3. How can I add the graphics rect items to a certain place
    By learning_qt in forum Qt Programming
    Replies: 2
    Last Post: 14th September 2009, 10:55
  4. Graphics View: Drawing Items that don't scale
    By Disperato in forum Qt Programming
    Replies: 5
    Last Post: 6th July 2009, 17:16
  5. Want custom menu items, like graphics, but how?
    By rm in forum Qt Programming
    Replies: 1
    Last Post: 30th January 2008, 20:52

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.