[Qt-interest] How to add Actions to DockWidget

varun singh mailthatmale at yahoo.co.in
Thu Jul 23 07:10:16 CEST 2009


Hi,

I'm facing this little problem about adding actions to the DockWidget.

Here is the code:

*****************************************************************************


MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
{
    mPaintWidget = new PaintWidget(this);
    this->setCentralWidget(mPaintWidget);

    createActions();
    mDockBar = new QDockWidget("Tools", this);
    addDockWidget(Qt::LeftDockWidgetArea, mDockBar, Qt::Vertical);
    addTools();


}

void MainWindow::addTools()
{
    mDockBar->addAction(mPenAction);
    mDockBar->addAction(mFColorAction);
    mDockBar->addAction(mBColorAction);
    mDockBar->addAction(mEraserAction);
}

void MainWindow::createActions()
{
    mPenAction = new QAction("P", this);
    mFColorAction = new QAction("F", this);
    mBColorAction = new QAction("B", this);
    mEraserAction = new QAction("E", this);
}

***********************************************************************************


The DockWidget gets initialzed and is visible but without actions.
Can anyone help?

-Varun




      Yahoo! recommends that you upgrade to the new and safer Internet Explorer 8. http://downloads.yahoo.com/in/internetexplorer/




More information about the Qt-interest-old mailing list