Results 1 to 7 of 7

Thread: Immediate help is required on QGraphicsTextItem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2008
    Posts
    51
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 4 Times in 4 Posts

    Question Immediate help is required on QGraphicsTextItem

    Hi,

    I have customized QGraphicsTextItem, added into scene.

    I want to align the text in that item.

    I tried following way but unable to get results.

    Please help me.

    alignment - is Qt::Alignment

    Qt Code:
    1. QTextCursor objCursor = textCursor();
    2. objCursor.movePosition(QTextCursor::Start);
    3. objCursor.movePosition(QTextCursor::StartOfBlock);
    4. QTextBlockFormat txtBlockFormat = objCursor.blockFormat();
    5. txtBlockFormat.setAlignment(alignment);
    6.  
    7. objCursor.setBlockFormat(txtBlockFormat);
    8.  
    9. //or
    10. objCursor.mergeBlockFormat(txtBlockFormat);
    11.  
    12. setTextCursor(objCursor);
    To copy to clipboard, switch view to plain text mode 

    The above code is supposed to align first block only.

    I am expecting the results shown in attached image file.

    Is there any other way to do it?

    Thanks in advance.

    Regards,
    Sandip
    Last edited by wysota; 19th November 2008 at 09:56. Reason: missing [code] tags

Similar Threads

  1. Rich text in QGraphicsTextItem
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 29th September 2008, 20:08
  2. QGraphicsTextItem AlphaColor Background to CSS2
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 30th November 2007, 15:17
  3. Problem on set QGraphicsTextItem write protect.
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2007, 20:53
  4. QGraphicsTextItem: handling cursor position change
    By Angelo Moriconi in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2007, 10:42
  5. QGraphicsTextItem size
    By Angelo Moriconi in forum Qt Programming
    Replies: 1
    Last Post: 26th January 2007, 08:34

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.