PDA

View Full Version : How to set the resizeHint of any bottom logReport window of MainWindow



santosh.kumar
4th September 2007, 05:20
hi all

I m creating one application that contains mainWindow..this mainWindow contains resizable Bottom Dockable LogReport Window...But problem is that when execute the mainWindow by defualt height of this LogReport window is more than i want....i want to set some minimumSizeHint so that while starting window it will come with this sizeHint...

How i will do this ...if anybody know then some sample code so that i will understand....

thanks
santosh

marcel
4th September 2007, 05:25
You have QDockWidget::setMinimumHeight but you can also impose this restriction on the widget that is contained by the dock widget.

Regards

santosh.kumar
4th September 2007, 07:19
hi

Actually i m usin one treeWidet inside the dockWidet .... According to u i used QDockWidet::setMinimumHeiht for both dockWidget and treeWidget.... but starting size is not coming according to my size...

it is taking other size by default.....

marcel
4th September 2007, 07:40
Do you have a layout set for the dockwidget?

santosh.kumar
4th September 2007, 08:02
no i have not set the layout for any dockWidget or treeWidget.....but for centralWidget i used layout....central Widget contains display tree with scrollbar....bottom dokwidget is resizable an working accordingly but problem is that by default height of treeWidget including dockwidget is more than prefect size......

marcel
4th September 2007, 08:05
That is why the minimum height is not respected. You need a layout set in the dock widget.

Add a vertical layout (QVBoxLayout) to the dock widget and add that tree widget to it. It will work this way when setting a minimum height for the treewidget.

Regards

darksaga
4th September 2007, 13:07
That is why the minimum height is not respected. You need a layout set in the dock widget.

Add a vertical layout (QVBoxLayout) to the dock widget and add that tree widget to it. It will work this way when setting a minimum height for the treewidget.

Regards

I'dont think this works


QVBoxLayout *dockLayout = new QVBoxLayout;
QDockWidget *dock = new QDockWidget("", this);
m_dockLog->setLayout(dockLayout);

i get following debugmessage:
QWidget::setLayout: Attempting to add QLayout "" to QDockWidget "" which already has a layout

marcel
4th September 2007, 13:09
In that case remove the first layout( delete it actually).
Take a look at the comments for setLayout in the docs.

Regards

santosh.kumar
4th September 2007, 13:25
QTreeWidget * m_pLogViewTreeWidget = new QTreeWidget;
m_pLogViewTreeWidget->setMinimumHeight(100);
QDockWidget *m_pLogReportDockWidget = new QDockWidget(tr("Log Report"),this);

m_pLogReportDockWidget->setAllowedAreas(Qt::BottomDockWidgetArea);
m_pLogReportDockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);

QVBoxLayout *pLayout = new QVBoxLayout;
pLayout->addWidget(m_pLogViewTreeWidget);
m_pLogReportDockWidget->setLayout(pLayout);

m_pLogReportDockWidget->setMinimumHeight(100);
addDockWidget(Qt::BottomDockWidgetArea,m_pLogRepor tDockWidget);


this bottom dockWidget set the layout and it by default it is coming 100 width that is fine ...but again problem is that when i use
pLayout ->addWidget(m_pLogViewTreeWidget) this treeWidget is not shown and added into dockwidget area...only layout is set...while i have already used addWidget;