Results 1 to 2 of 2

Thread: QTextEdit, sizeHint, QWidget

  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default QTextEdit, sizeHint, QWidget

    I've got a QTextEdit inside a sub-class of QWidget. I just want to display some simple (rich) text. I'd like the QTextEdit to scale to it's contents and the window around it around it to scale too.

    Qt Code:
    1. class MyThing: public QWidget
    2. {
    3. MyThing(QWidget* parent = 0);
    4. //...etc
    5.  
    6. private:
    7. QTextEdit* txtEdit;
    8. }
    9. //the constructor
    10. MyThing(QWidget *parent): QWidget (parent)
    11. {
    12. txtEdit= new QTextEdit(this) ;
    13. QWidget::setFixedSize(txtEdit->sizeHint());
    14. }
    To copy to clipboard, switch view to plain text mode 
    I think the problem is that txtEdit->sizeHint() is not influenced by the (small) amount of text in the QTextEdit. Is there any way of telling QTextEdit to occupy the minimum space possible for the given text formatting?

    thanks
    K

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTextEdit, sizeHint, QWidget

    Maybe QTextDocument::size() is what you are looking for? QLabel is also one possibility in case the text is just shown and not meant to be modified.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    TheKedge (5th February 2007)

Similar Threads

  1. Re-implement mouse events of QTextEdit
    By Ankitha Varsha in forum Qt Programming
    Replies: 2
    Last Post: 14th October 2006, 17:55
  2. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 07:03
  3. Replies: 1
    Last Post: 2nd May 2006, 22:11
  4. [QT 4] QTextEdit performance
    By fellobo in forum Qt Programming
    Replies: 8
    Last Post: 6th March 2006, 20:27
  5. Obtaining clean (x)html from QTextEdit
    By ccf_h in forum Qt Programming
    Replies: 1
    Last Post: 5th February 2006, 15:47

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.