PDA

View Full Version : QTextEdit preferred height



darksaga
21st May 2007, 15:40
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:



QDockWidget m_dockLog = new QDockWidget("", this);
m_dockLog->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);

QTabWidget m_logTabWidget = new QTabWidget(m_dockLog);
m_logTabWidget->setTabPosition(QTabWidget::South);

QTextEdit m_textEditLog = new QTextEdit(m_logTabWidget);

m_logTabWidget->addTab(m_textEditLog, "");
m_dockLog->setWidget(m_logTabWidget);


I tried to set the preferred height using:
m_textEditLog->resize(QSize(m_textEditLog->width(),100)); but this does nothing.

using
m_textEditLog->setMaximumHeight(100); 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

darksaga
23rd May 2007, 03:03
found a solution for my prob, after i've read a thread (http://www.qtcentre.org/forum/f-qt-programming-2/t-qdockwidget-nesting-problem-5400.html) about QDockWidget and resizing :D .

subclassing QDockWidget & setting a appropriate minimum sizeHint solves the prob:


#ifndef MYDOCKWIDGET_H
#define MYDOCKWIDGET_H
class MyDockWidget : public QDockWidget
{
public:
MyDockWidget(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0)
:QDockWidget(title,parent, flags)
{
setWindowTitle(title);
setAllowedAreas(Qt::AllDockWidgetAreas);
szHint = QSize(-1, -1); //initial size
minSzHint = QSize(100, 100); //minimum size
}

virtual QSize sizeHint() const
{
return szHint;
}

virtual QSize minimumSizeHint() const
{
return minSzHint;
}

private:
QSize szHint, minSzHint;
};
#endif