[SOLVED] help in getting focus to the dialog
-
yes. here is the code to the displaying of the dialog.
dialog.h
@#ifndef DIALOG_H
#define DIALOG_H#include <QDialog>
namespace Ui {
class Dialog;
}class Dialog : public QDialog
{
Q_OBJECTpublic:
explicit Dialog(QWidget *parent = 0);
~Dialog();private:
Ui::Dialog *ui;
};#endif // DIALOG_H@
mainwindow.h
@#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
class Dialog;
namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();private:
Ui::MainWindow *ui;
Dialog *tt;
};#endif // MAINWINDOW_H@
dialog.cpp
@#include "dialog.h"
#include "ui_dialog.h"Dialog::Dialog(QWidget *child) :
QDialog(child),
ui(new Ui::Dialog)
{
ui->setupUi(this);
}Dialog::~Dialog()
{
delete ui;
}@mainwindow.cpp
@#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "dialog.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
Dialog *tt = new Dialog(this);
tt->show();
}MainWindow::~MainWindow()
{
delete ui;
}@ -
I'm not sure offhand (it's late here and I'm tired). You may be able to play with the "focusPolicy":http://doc.qt.nokia.com/latest/qwidget.html#focusPolicy-prop on your MainWindow (or it's components) and your Dialog. But that's just speculation. I'm not sure on what the details would be to implement such a thing.
-
-
this topic is solved. I showed the mainwindow first and then the dialog right after it as in this code and it works great. i stumbled on this fix after i read Volker post.
comment the w.show(); in main.cpp and add this code to your mainwindow.cpp file
@this->show();
Dialog->show();@