Sjaacko
21st September 2011, 07:58
Hi all,
In my program I have a widget where a text file is loaded and where you can edit it.
Various actions that the program does also adds (or removes) content from the file.
This is the code that creates it.
void Gui::createDockWindows()
{
QDockWidget *dock = new QDockWidget(tr("File"), this);
dock->setAllowedAreas(
Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea |
Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
dock->setWidget(editWindow);
addDockWidget(Qt::RightDockWidgetArea, dock);
viewMenu->addAction(dock->toggleViewAction());
}
The question is: how do I auto resize the width of the widget when content is changed to the max width of the longest line of text?
I found this can probably done with adjustSize() or QWidget::sizeHint() but I don't know where to put it.
Please help?
Thank you.
Sjaacko
In my program I have a widget where a text file is loaded and where you can edit it.
Various actions that the program does also adds (or removes) content from the file.
This is the code that creates it.
void Gui::createDockWindows()
{
QDockWidget *dock = new QDockWidget(tr("File"), this);
dock->setAllowedAreas(
Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea |
Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
dock->setWidget(editWindow);
addDockWidget(Qt::RightDockWidgetArea, dock);
viewMenu->addAction(dock->toggleViewAction());
}
The question is: how do I auto resize the width of the widget when content is changed to the max width of the longest line of text?
I found this can probably done with adjustSize() or QWidget::sizeHint() but I don't know where to put it.
Please help?
Thank you.
Sjaacko