Results 1 to 2 of 2

Thread: QTextEdit preferred height

  1. #1
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default QTextEdit preferred height

    Hi all,

    maybe I'm blind, but I didn't find any way to set the preferred height of a QTextEdit?

    what I'm trying to do:

    Qt Code:
    1. QDockWidget m_dockLog = new QDockWidget("", this);
    2. m_dockLog->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
    3.  
    4. QTabWidget m_logTabWidget = new QTabWidget(m_dockLog);
    5. m_logTabWidget->setTabPosition(QTabWidget::South);
    6.  
    7. QTextEdit m_textEditLog = new QTextEdit(m_logTabWidget);
    8.  
    9. m_logTabWidget->addTab(m_textEditLog, "");
    10. m_dockLog->setWidget(m_logTabWidget);
    To copy to clipboard, switch view to plain text mode 

    I tried to set the preferred height using:
    Qt Code:
    1. m_textEditLog->resize(QSize(m_textEditLog->width(),100));
    To copy to clipboard, switch view to plain text mode 
    but this does nothing.

    using
    Qt Code:
    1. m_textEditLog->setMaximumHeight(100);
    To copy to clipboard, switch view to plain text mode 
    also doesn't solve the prob, coz then the Textedits height won't change when you change the height of the QDockWidget.

    hope somebody knows a solution...

    greetz
    darksaga

  2. #2
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: QTextEdit preferred height

    found a solution for my prob, after i've read a thread about QDockWidget and resizing .

    subclassing QDockWidget & setting a appropriate minimum sizeHint solves the prob:
    Qt Code:
    1. #ifndef MYDOCKWIDGET_H
    2. #define MYDOCKWIDGET_H
    3. class MyDockWidget : public QDockWidget
    4. {
    5. public:
    6. MyDockWidget(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0)
    7. :QDockWidget(title,parent, flags)
    8. {
    9. setWindowTitle(title);
    10. setAllowedAreas(Qt::AllDockWidgetAreas);
    11. szHint = QSize(-1, -1); //initial size
    12. minSzHint = QSize(100, 100); //minimum size
    13. }
    14.  
    15. virtual QSize sizeHint() const
    16. {
    17. return szHint;
    18. }
    19.  
    20. virtual QSize minimumSizeHint() const
    21. {
    22. return minSzHint;
    23. }
    24.  
    25. private:
    26. QSize szHint, minSzHint;
    27. };
    28. #endif
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QTextEdit height using Qt3.3.5
    By vermarajeev in forum Qt Programming
    Replies: 3
    Last Post: 15th December 2006, 08:43

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.