Results 1 to 4 of 4

Thread: Setting QGraphicsTextItem height?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Setting QGraphicsTextItem height?

    Does anyone know how to specify the height of a QGraphicsTextItem? I've tried a number of ways and nothing seems to work.

    Qt Code:
    1. text.document()->setPageSize( QSizeF( 300,40) );
    2.  
    3. qreal w = text.document()->size().width(); // 300 - correct
    4. qreal h = text.document()->size().height(); // 22 - why???
    To copy to clipboard, switch view to plain text mode 

    I've also tried setting the size property directly on QTextDocument but the same thing happens, it accepts the width but not the height.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Setting QGraphicsTextItem height?

    Why? Have a look into the docs! There you can find for size:
    Returns the actual size of the document. This is equivalent to documentLayout()->documentSize();
    If you want the size of the document use QTextDocument::pageSize().

  3. #3

    Default Re: Setting QGraphicsTextItem height?

    Returns the actual size of the document.
    That is what I care about, the actual size. The problem is, I am specifying the size I want it to be - 40 - but it doesn't take.

    The actual size, not page size, seems to determine how it will be drawn. So I could do this:

    Qt Code:
    1. text.document()->setPageSize(QSizeF(300,300));
    To copy to clipboard, switch view to plain text mode 

    and it will be drawn on screen with a width of 300, and a height of 28. I want it to draw with a height of 300.

  4. #4

    Wink Re: Setting QGraphicsTextItem height?

    change the font point size ,can change the height of the QGraphicsTextItem .
    This function would help you?

Similar Threads

  1. Same height for QComboBox and QPushButton
    By cevou in forum Qt Programming
    Replies: 5
    Last Post: 12th May 2012, 07:56
  2. QLayout: different SizeConstraints for width and height?
    By PhilippB in forum Qt Programming
    Replies: 0
    Last Post: 23rd February 2009, 16:33
  3. Replies: 0
    Last Post: 13th February 2009, 15:17
  4. How can I get the Systray height ?
    By Nyphel in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2007, 09:04
  5. height()
    By mickey in forum Newbie
    Replies: 1
    Last Post: 22nd March 2006, 20:32

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.