The main window has an empty QVBoxLayout layout and we could add our widgets directly to this layout, but for keyboard + shortcuts to work properly, we need a widget that fills the main window. We create a master widget, add it to the main window + layout and then fill the master widget with other widgets.
+bool Module::init(QString const & args) { Q_UNUSED(args); @@ -134,12 +138,15 @@ Module::~Moduleif (!mStorage) EVAF_WARNING("No iStorage interface"); - // Get the main window interface and fill it with widgets + // Get the main window interface and fill it with the widgets SdiWindow::iSdiWindow * win = evafQueryInterface<SdiWindow::iSdiWindow>("iSdiWindow"); EVAF_TEST_X(win, "No iSdiWindow interface"); + QWidget * masterWidget = new QWidget; + win->addWidget(masterWidget); + QVBoxLayout * v = new QVBoxLayout; - win->widget()->setLayout(v); + masterWidget->setLayout(v); QGridLayout * g = new QGridLayout; v->addLayout(g); @@ -169,7 +176,7 @@ Module::~Module} connect(wName, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); g->addWidget(wName, 1, 1, 1, 2); - win->widget()->setFocusProxy(wName); + masterWidget->setFocusProxy(wName); l = new QLabel(tr("&Length of the password:", VER_MODULE_NAME_STR)); l->setAlignment(Qt::AlignRight); @@ -207,15 +214,15 @@ Module::~Moduleconnect(wCopy, SIGNAL(clicked()), this, SLOT(copyClicked())); h->addWidget(wCopy); - QAction * a = new QAction(win->widget()); + QAction * a = new QAction(masterWidget); a->setShortcut(Qt::Key_Return); connect(a, SIGNAL(triggered()), this, SLOT(generateClicked())); - win->widget()->addAction(a); + masterWidget->addAction(a); - a = new QAction(win->widget()); + a = new QAction(masterWidget); a->setShortcut(Qt::Key_Escape); connect(a, SIGNAL(triggered()), qApp, SLOT(quit())); - win->widget()->addAction(a); + masterWidget->addAction(a); mReady = true; @@ -342,8 +349,11 @@ Module::~Module::iSdiWindow * win = evafQueryInterface<SdiWindow::iSdiWindow>("iSdiWindow"); EVAF_TEST_X(win, "No iSdiWindow interface"); + QWidget * masterWidget = new QWidget; + win->addWidget(masterWidget); + QVBoxLayout * v = new QVBoxLayout; - win->widget()->setLayout(v); + masterWidget->setLayout(v); QGridLayout * g = new QGridLayout; v->addLayout(g); @@ -373,7 +383,7 @@ Module::~Module} connect(wName, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); g->addWidget(wName, 1, 1, 1, 2); - win->widget()->setFocusProxy(wName); + masterWidget->setFocusProxy(wName); l = new QLabel(tr("&Length of the password:", VER_MODULE_NAME_STR)); l->setAlignment(Qt::AlignRight); @@ -411,15 +421,15 @@ Module::~Moduleconnect(wCopy, SIGNAL(clicked()), this, SLOT(copyClicked())); h->addWidget(wCopy); - QAction * a = new QAction(win->widget()); + QAction * a = new QAction(masterWidget); a->setShortcut(Qt::Key_Return); connect(a, SIGNAL(triggered()), this, SLOT(generateClicked())); - win->widget()->addAction(a); + masterWidget->addAction(a); - a = new QAction(win->widget()); + a = new QAction(masterWidget); a->setShortcut(Qt::Key_Escape); connect(a, SIGNAL(triggered()), qApp, SLOT(quit())); - win->widget()->addAction(a); + masterWidget->addAction(a); mReady = true;