PDA

View Full Version : Remove restore button



vermarajeev
26th June 2007, 12:02
Hi guys,
I have a QMainWindow. In the menuBar 'Edit' I click "show Dock Widget". The dockWidget appears. Now I want to remove the " restore button" just next to "close button". I tried setting the windows flags but was unsuccessful.

Please help me to remove the restore button displayed on dockWidget.



MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QAction* newAct = new QAction(QIcon(":/images/new.png"), QObject::tr("&New"), this);
newAct->setShortcut(QObject::tr("Ctrl+N"));

QAction* dockAct = new QAction(QIcon(":/images/cut.png"), QObject::tr("Show Dock Widget"), this);
dockAct->setShortcut(QObject::tr("Ctrl+D"));

connect(dockAct, SIGNAL(triggered()), this, SLOT(showDockWidget()));

QMenu *fileMenu = menuBar()->addMenu(QObject::tr("&File"));
fileMenu->addAction(newAct);

QMenu *editMenu = menuBar()->addMenu(QObject::tr("&Edit"));
editMenu->addAction(dockAct);
}

MainWindow::~MainWindow()
{}

void MainWindow::showDockWidget()
{
_dock = new QDockWidget(this);
_dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);

_dock->setFeatures (QDockWidget::AllDockWidgetFeatures);
_dock->setFloating ( true );

QToolButton* btn_1 = new QToolButton();
_dock->setWidget( btn_1 );

//setWindowFlags( Qt::WStyle_Customize|Qt::WStyle_Title );

_dock->setGeometry( width()/2, height()/2, 100, 30 );
_dock->show();
}

Thanks

wysota
26th June 2007, 12:39
Did you try to set the flags on the _dock object and not on the content?

vermarajeev
26th June 2007, 12:48
Did you try to set the flags on the _dock object and not on the content?

Yes I tried on _dock but it didnt work.

_dock->setWindowFlags( Qt::WStyle_Customize|Qt::WStyle_Title );

jpn
26th June 2007, 13:29
_dock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);