#include class Widget : public QWidget { public: Widget() { setObjectName("container"); QLineEdit *le = new QLineEdit(this); le->setObjectName("qlineedit"); m_editor = le; QHBoxLayout *l = new QHBoxLayout(this); l->addWidget(m_editor); } QWidget *m_editor; }; class Dialog : public QDialog { Q_OBJECT public: Dialog() { setObjectName("dialog"); toolbar = new QToolBar; toolbar->setObjectName("toolbar"); QAction *action = new QAction("foo", this); connect(action, SIGNAL(triggered()), this, SLOT(foo())); toolbar->addAction(action); toolbar->addWidget(new Widget); QVBoxLayout *l = new QVBoxLayout(this); l->addWidget(toolbar); } QToolBar *toolbar; public Q_SLOTS: void foo() { qDebug("foo"); Dialog d; d.exec(); } }; class W : public QWidget { Q_OBJECT public: W() { setObjectName("W"); QPushButton *b = new QPushButton("click me", this); QVBoxLayout *l = new QVBoxLayout(this); l->addWidget(b); l->addWidget(new QLineEdit); connect(b, SIGNAL(clicked()), this, SLOT(fla())); } public Q_SLOTS: void fla() { qDebug("fla"); Dialog d; d.exec(); } }; int main(int argc, char **argv) { QApplication app(argc, argv); // Dialog d; // d.show(); W w; w.show(); return app.exec(); } #include "main.moc"