PDA

View Full Version : [SOLVED] QDockWidget::setVisible() doesn't work



Oleg
4th January 2008, 19:51
Hi all. I have a problem with hiding/showing QDockWidget.
So, I have a QDockWidget


QDockWidget *DiskInfoWidget = new QDockWidget ( tr ( "Disk Information" ), this );
DiskInfoWidget->setFeatures ( QDockWidget::NoDockWidgetFeatures );
DiskInfoWidget->setContextMenuPolicy ( Qt::PreventContextMenu );
addDockWidget ( Qt::TopDockWidgetArea, DiskInfoWidget );
DiskInfoWidget->hide();

a QAction to control it


DiskInfoAction = new QAction ( QIcon ( ":/toolbar/information" ), tr ( "Disk Information" ), this );
DiskInfoAction->setCheckable ( true );
DiskInfoAction->connect ( DiskInfoAction, SIGNAL ( triggered ( bool ) ), this, SLOT ( showDiskInfoWidget ( bool ) ) );

and here is a slot for triggered()


void cwFMWindow::showDiskInfoWidget ( bool checked )
{
DiskInfoWidget->setVisible ( checked );
}

And all this code does absolutely nothing. I can't guess why... It seems that I miss some stupid reason.
Thanks for help :)

wysota
4th January 2008, 20:12
A wild guess - missing Q_OBJECT macro or showDiskInfoWidget not declared as a slot? Check if Qt gives you any warnings in the console.

Oleg
4th January 2008, 20:27
OMG. It was a really stupid bug. It seems I'm too tired. There were two different QDockObject *DiskInfoWidget in class and in the function. Sorry for posting. Unfortunately I couldn't find a way to delete my thread. :(