PDA

View Full Version : Adding a QToolbar on QLayout to the QWidget, it is shown like a "picture"!



tguglanaklona
20th September 2010, 10:58
I add a QToolbar on QLayoutе to QWidget, but it behaves like a "picture" (can not press the buttons), please, help!

P.S.: Commented sample workson a new window, but I need the current one.

I've done everything I can! Please, help! :)


clonewidget.h

class CloneWidget : public QDockWidget, public CloneWidgetClass
{
Q_OBJECT

public:
CloneWidget(QWidget *parent);
~CloneWidget();

...

QToolBar toolbar;
QVBoxLayout lay0t;

QAction actionNew;

...
private slots:

void on_newMenu_clicked();
...

};

clonewidget.cpp

CloneWidget::CloneWidget(QWidget *parent)
: QDockWidget(parent), applicationName("Parser Window")
, toolbar("Macros Editor Toolbar", this), lay0t(this), actionNew(this)...
{
...
}

void CloneWidget::CreateMacroWindow()
{
setupUi(this);

this->setFloating(1);
toolbar.setFloatable(1);

actionNew.setText("&New");
toolbar.addAction(&actionNew);

setLayout(&lay0t);
lay0t.addWidget(&toolbar);

actionNew.setEnabled(true);
connect(&actionNew,SIGNAL(triggered()),this,SLOT(on_newMenu _clicked()));
...

//sample
/*
QWidget * widget = new QWidget;
QVBoxLayout * layout = new QVBoxLayout( widget );
layout->addWidget( &toolbar );
this->setWidget( widget );
*/
...
this->adjustSize();

}

xxx.h

CloneWidget wndMacro;

xxx.cpp

wndMacro.CreateMacroWindow();
mainWnd->addDockWidget(Qt::NoDockWidgetArea, &wndMacro);
wndMacro.setFloating(1);
wndMacro.setWindowModality(Qt::ApplicationModal);
wndMacro.show();