Results 1 to 4 of 4

Thread: QTextEdit Alignment won't stick

  1. #1
    Join Date
    Feb 2006
    Location
    Boulder, Colorado, USA
    Posts
    63
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTextEdit Alignment won't stick

    How do I get QTextEdit to always be aligned the way I want? I can change it just fine with this:

    Qt Code:
    1. textEdit->setAlignment(Qt::AlignJustify);
    To copy to clipboard, switch view to plain text mode 

    I can call this before text is entered into the text edit and it will remain aligned as long as the user edits the text, but if the user pastes texts with multiple blocks or I programmaticaly set the text, the formating is lost. I understand that is how the code snip it above works, but is there a better way, that would make it stick> Otherwise, I'll just have catch contentsChanged signals and reapply the formating each time.

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit Alignment won't stick

    Could it be that the pasted text is right-aligned and that the QTextEdit accepts rich text/html - i.e. text that carries alignment data with it.

  3. #3
    Join Date
    Feb 2006
    Location
    Boulder, Colorado, USA
    Posts
    63
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit Alignment won't stick

    No, I've set it so that: textEdit->setAcceptRichText(false);

  4. #4
    Join Date
    Nov 2006
    Posts
    72
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit Alignment won't stick

    I have similar problem. I use this control and also set alignment to (Qt::AlignJustify) but when i set text in it (which I read from some file), it appears at the center of control. I use setPlaintText() method to put text in this control. I've tried (Qt::AlignLeft|Qt::AlignTop) but the text is still in center, oddly broke. I want it broken in way that there is no need for horizontal slider, just vertical needs to be shown (if there is need for that at all, that is). Does anybody know what I need to set?

Similar Threads

  1. Re-implement mouse events of QTextEdit
    By Ankitha Varsha in forum Qt Programming
    Replies: 2
    Last Post: 14th October 2006, 16:55
  2. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03
  3. QTextEdit Alignment
    By vijay anandh in forum Qt Programming
    Replies: 1
    Last Post: 2nd May 2006, 07:44
  4. [QT 4] QTextEdit performance
    By fellobo in forum Qt Programming
    Replies: 8
    Last Post: 6th March 2006, 19:27
  5. Painting to QTextEdit
    By gesslar in forum Qt Programming
    Replies: 8
    Last Post: 18th February 2006, 18:40

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.