Hey there,
I'm french, so I apologize in advance for my english. I'm also a complete beginner, and I apologize as well for writing things that might not be true. I'm really interested in Qt since I got a new N8 phone, and I'm trying to learn and understand the most of this wonderful language.
Here is my problem: I have a QMainWindow.ui, which is my main interface, and I'm trying to open a new window (QWidget) by pressing on an "info" QPushButton. Into the constructor of my MainWindow, I created a new instance of the "info" QWidget, and I connected the QPushButton with info.show(). Then, on this info widget now showing up, I have a BtnReturn (QPushButton) to go back to my main screen. Into the constructor of the Information (QWIdget), i created a connection between BtnRetour and this.close(). ALl of this works like a charm. My only problem is that into the MainWindow, after closing the QWidget, the QLineEdit are completely disabled... and I dont understand why... I can still put a cursor inside them, but any pressed key won't show up, like if the input wasn't working... Please help! Again, sorry for the mistakes, I'm still learning
my Main.cpp
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#include "mainwindow.h"
#include "information.h"
#include <QtGui/QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow mainWindow;
mainWindow.setOrientation(MainWindow::ScreenOrientationAuto);
mainWindow.showFullScreen();
return app.exec();
}
|
my MainWindow.h
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtGui/QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
virtual ~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
|
my MainWIndow.cpp
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QObject"
#include "information.h"
#include "ui_information.h"
#include <QtCore/QCoreApplication>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
//SETTING THE MASKS ONTO THE QLINEEDIT
QDoubleValidator *doubleValidator=new QDoubleValidator();
doubleValidator->setTop(10000.00);
doubleValidator->setBottom(0.00);
doubleValidator->setDecimals(2);
ui->TxtBudget->setValidator(doubleValidator);
ui->TxtPrix->setValidator(doubleValidator);
//CREATING THE CONNECTIONS
Information* info = new Information(0);
QObject::connect(ui->BtnQuitter, SIGNAL(clicked()), this, SLOT(close()));
QObject::connect(ui->BtnInfo, SIGNAL(clicked()), info, SLOT(showFullScreen())); //opens the QWidget "info"
}
|
my Information.cpp
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
#include "information.h"
#include "ui_information.h"
#include "ui_mainwindow.h"
#include "mainwindow.h"
#include <QObject>
Information::Information(QWidget *parent) :
QWidget(parent),
ui(new Ui::Information)
{
ui->setupUi(this);
QObject::connect(ui->BtnRetour, SIGNAL(clicked()), this, SLOT(close()));
}
|