Results 1 to 3 of 3

Thread: How to have fixed size QGraphicsView & QGraphicsScene

  1. #1
    Join Date
    Aug 2012
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default How to have fixed size QGraphicsView & QGraphicsScene

    I'm trying to have a fixed size wysiwyg editor for creating labels. Currently I am trying to implement this with a QGraphicsScene & QGraphicsView populated with QGraphicsTextItem that will take up the whole view.

    The problem I am having is how in the world do I get the QGraphicsView to be the same size as the scene, I need this to be a fixed size so that I can use it to do autosizing on the text within it. There are so many different ways I have seen attempted to do this such as using contentsRect(), viewport->setFixedSize(), using setSceneRect(). I also have the border-style set to none and setFrameStyle(QFrame::NoFrame). But alas I just cannot get this to work.

    Am doing something wrong or is this the wrong approach. I really don't want to have to implement a complete custom widget to do all this when most of the functionality is built into the QGraphicsTextItem.

  2. #2
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to have fixed size QGraphicsView & QGraphicsScene

    So you want to have a fixed size for the QGraphicsView and the QGraphicsScene ?
    Or you want to resize the QGraphicsView and QGraphicsScene to the size of the text?

  3. #3
    Join Date
    Aug 2012
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to have fixed size QGraphicsView & QGraphicsScene

    A Fixed size for the QGraphicsView & QGraphicsScene. I basically want to use a view the exact same size as the scene. The fact that there even is a scene is just a fact of the way qt works, I don't care about it, I just want a fixed size widget to add QGraphicTextItems into. The Text will simply be autosized by using the size of the QRect of the view and checking the bounding rect of the font with QFontMetrics.

Similar Threads

  1. Fixed QGraphicsScene in view
    By jano_alex_es in forum Newbie
    Replies: 1
    Last Post: 10th May 2012, 01:29
  2. Replies: 2
    Last Post: 20th February 2012, 07:30
  3. Replies: 0
    Last Post: 14th February 2012, 15:43
  4. How to fixed the size of the QGraphicsScene.?
    By syclopse in forum Qt Programming
    Replies: 9
    Last Post: 4th July 2011, 13:41
  5. Replies: 4
    Last Post: 20th November 2009, 12:25

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.