Results 1 to 8 of 8

Thread: QGraphicsTextItem - setHTML()

Hybrid View

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

    Default Re: QGraphicsTextItem - setHTML()

    Hello.I have a question, When I using the QGraphcisTextItem , I will set the document 's width to Align the text?

    Do you any method to change the alignment ,but no need to using setTextWidth()?

    Thank you very much!

  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: QGraphicsTextItem - setHTML()

    Quote Originally Posted by robertkun View Post
    Do you any method to change the alignment ,but no need to using setTextWidth()?
    QGraphicsTextItem::document() -> QTextDocument::setDefaultTextOption() and then see the various options for QTextOption.

  3. #3

    Question Re: QGraphicsTextItem - setHTML()

    Thank you , LyKurg
    Here is my program:

    void cgStaticTextElement::slot_onSetTextAlign( FParam* param )
    {
    int alignFlag = param->getValue<int>();
    QTextOption option = document()->defaultTextOption ();
    Qt::AlignmentFlag flags((Qt::AlignmentFlag)(alignFlag));
    option.setAlignment ( flags );
    document()->setDefaultTextOption ( option );
    notifyReCache(this);
    }

    the option in this,have a right value ,like Qt::AlignRight , but the text in the QGraphcisTextItem 's Alignment not change.
    If I have modif my program like this :

    void cgStaticTextElement::slot_onSetTextAlign( FParam* param )
    {
    int alignFlag = param->getValue<int>();
    QTextOption option = document()->defaultTextOption ();
    document()->setTextWidth(200); //At here give a fixed value
    Qt::AlignmentFlag flags((Qt::AlignmentFlag)(alignFlag));
    option.setAlignment ( flags );
    document()->setDefaultTextOption ( option );
    notifyReCache(this);
    }

    the Alignment of the QGraphcisTextItem have changed...

    I don't know why ? Would you give me a reason? Thank you .

Similar Threads

  1. QGraphicsTextItem - is it a bug there?
    By Tair in forum Qt Programming
    Replies: 5
    Last Post: 18th October 2006, 08:48

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.