Qt sending Object from a form to mainwindow - c++

I have an assignment and I'm not too sure on how to approach it,at the moment I have 2 window.
-> MainWindow and PlayerForm.
From a menu, I call PlayerFrom and with this form I create a object player.
My question is How can I send back this object to a label in my main window ?
Player Slot :
void MainWindow::on_actionJoueur_triggered()
{
FormulaireJoueur *fj = new FormulaireJoueur;
fj->show();
}
Form OK Slot :
void FormulaireJoueur::on_OkJoueur_clicked()
{
try
{
std::string Nom = (ui->J_Nom->text()).toStdString();
std::string Prenom = (ui->J_Prenom->text()).toStdString();
std::string Telephone = (ui->J_Phone->text()).toStdString();
std::string Position = (ui->J_Pos->text()).toStdString();
QDate Date = ui->J_Date->date();
int jour = Date.day();
int mois = Date.month();
int annee = Date.year();
util::Date DateJoueur(jour,mois,annee);
Joueur NouveauJoueur(Nom,Prenom,DateJoueur,Telephone,Position);
std::string Message = NouveauJoueur.reqPersonneFormate();
}
catch(ContratException e)
{
QMessageBox::information(this,"Erreur","Erreur lors de la création du joueur.");
}
}
FormulaireJoueur.h :
#ifndef FORMULAIREJOUEUR_H
#define FORMULAIREJOUEUR_H
#include <QMainWindow>
namespace Ui {
class FormulaireJoueur;
}
class FormulaireJoueur : public QMainWindow
{
Q_OBJECT
public:
explicit FormulaireJoueur(QWidget *parent = 0);
~FormulaireJoueur();
private slots:
void on_OkJoueur_clicked();
void on_AnnulerJoueur_clicked();
private:
Ui::FormulaireJoueur *ui;
};
#endif // FORMULAIREJOUEUR_H
Container :
Annuaire AnnuairePrincipal("Canadiens");
AnnuairePrincipal.AjouterPersonne(NouveauJoueur);

edit : FormulaireJoueur should inherits from QDialog as it is a dialog
edit again : closeEvent forgotten
add Joueur at your FormulaireJoueur class, and add a public getter to it
I assumed that you use directly the Joueur type and that the copy constructor is correct
Joueur FormulaireJoueur::getJoueur()
{
return this->_joueur;
}
in your MainWindow.h add a slot
void FomulaireJoueurFinished(int return)
then in your player slot :
void MainWindow::on_actionJoueur_triggered()
{
FormulaireJoueur *fj = new FormulaireJoueur;
connect(fj, SIGNAL(finished ( int)), this, SLOT(FomulaireJoueurFinished(int return));
fj->show();
}
then in MainWindow.cpp
void MainWindow::FomulaireJoueurFinished(int return)
{
if (return == QDialog::Accepted)
this->AnnuairePrincipal.AjouterPersonne((static_cast<FormulaireJoueur *>(sender))->getJoueur());
}
you also should override closeEvent of the FormulaireJoueur Dialog
void QDialog::closeEvent ( QCloseEvent * e ) [virtual protected]
to integrate your verification and generation of Joueur

Related

How to use the signal QMovie::frameChanged(int frameNumber) to emit a signal?

I want to use the frameChanged(int) to emit a signal when the currentFrameNumber is equal to the frameCount, my QT version is 4.7.4
QObject::connect(movie,SIGNAL(frameChanged(int)),movie,SLOT(stop()));
QMovieChild.cpp:
class QMovieChild:public QMovie
{
signals:
void newSignal();
public slots:
void onFrameChanged(int frameNumber){
if(frameNumber == this->frameCount()-2)
emit newSignal();
}
};
Monster.cpp:
void Monster::Vanishment()
{
QMovieChild *movie = new QMovieChild();
movie->setFileName("./pikaqiu.gif");
QSize size = this->getLabelPointer()->size();
movie->setScaledSize(size);
this->getLabelPointer()->setMovie(movie);
QMovie::connect(movie,SIGNAL(newSignal()),movie,SLOT(deleteLater()));
QMovie::connect(movie,SIGNAL(frameChanged(int)),movie,SLOT(onFrameChanged(int)));
movie->start();
}
To create a signal the class should inherit from QObject, if the class you use is QWidget, it is also valid since it inherits from QObject.
#ifndef QMOVIECHILD_H
#define QMOVIECHILD_H
#include <QMovie>
class QMovieChild : public QMovie
{
Q_OBJECT
public:
QMovieChild(QObject * parent = 0):QMovie(parent){
connect(this, SIGNAL(frameChanged(int)), this, SLOT(onFrameChanged(int)));
}
signals:
void newSignal();
private slots:
void onFrameChanged(int frameNumber){
if(frameNumber == frameCount()-1){
emit newSignal();
//stop();
}
}
};
#endif // QMOVIECHILD_H
Use:
QMovieChild *movie = new QMovieChild;
movie->setFileName("./pikaqiu.gif");
QMovie::connect(movie,SIGNAL(newSignal()),movie,SLOT(deleteLater()));
QSize size = getLabelPointer()->size();
movie->setScaledSize(size);
getLabelPointer()->setMovie(movie);
movie->start();

Qt5/C++ release mouse during mousePressEvent

I've a QGridLayout where each cell contains my custom widget QFrameExtended defined as follow:
In .h:
#ifndef QFRAMEEXTENDED_H
#define QFRAMEEXTENDED_H
#include <QObject>
#include <QFrame>
class QFrameExtended : public QFrame
{
Q_OBJECT
private:
public:
int id;
explicit QFrameExtended(QWidget *parent = 0);
signals:
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void pressed(QFrameExtended *);
void released(QFrameExtended *);
public slots:
void on_mouse_press();
void on_mouse_release();
};
#endif // QFRAMEEXTENDED_H
In .cpp:
#include "qframe_extended.h"
QFrameExtended::QFrameExtended(QWidget *parent) : QFrame(parent)
{
this->id = /* Imagine here there is a function to generate an id */ ;
connect( this, SIGNAL( mousePressEvent(QMouseEvent*) ), this, SLOT( on_mouse_press() ) );
connect( this, SIGNAL( mouseReleaseEvent(QMouseEvent*) ), this, SLOT( on_mouse_release() ) );
}
void QFrameExtended::on_mouse_press() {
emit pressed(this);
}
void QFrameExtended::on_mouse_release() {
emit released(this);
}
My form creates the QGridLayout with the QFrameExtended widgets and for each of them defines an event handler:
/* ... */
/* This snippet of code is inside a loop that is creating frame objects */
connect(frame, &QFrameExtended::pressed, this, &MyForm::on_mouse_press);
connect(frame, &QFrameExtended::released, this, &MyForm::on_mouse_release);
/* ... */
and finally these are the event handlers:
void MyForm::on_mouse_press(QFrameExtended *frame) {
qDebug() << "Pressed here: " << frame->id << endl;
}
void MyForm::on_mouse_release(QFrameExtended *frame) {
qDebug() << "Released here: " << frame->id << endl;
}
When I click on a cell (i.e. a QFrameExtended widget) without release the button, I would see printed on the console the id of the cell. After I moved the mouse over another cell, when I release the button I would see printed the second id.
An example is an output like this:
Pressed here: 1
Released here: 3
but the reality is that when I press the mouse button over a QFrameExtended, he starting to grab all mouse events until I release the button. This is the expected behaviour:
Qt automatically grabs the mouse when a mouse button is pressed inside a widget; the widget will continue to receive mouse events until the last mouse button is released.
From: http://doc.qt.io/qt-4.8/qmouseevent.html
How can I change this behaviour? I'll really appreciate if you can give me also an example
Ok, I resolved following the tip of peppe. I tried to extend the QGridLayout but layouts don't support mouse events, because don't inherit from QWidget. So, I extended the QWidget that contains the layout.
In .h:
#ifndef QWIDGETEXTENDED_H
#define QWIDGETEXTENDED_H
#include <QWidget>
#include <QString>
#include <QMouseEvent>
#include "qframe_extended.h"
class QWidgetExtended : public QWidget
{
Q_OBJECT
public:
explicit QWidgetExtended(QWidget *parent = 0);
protected:
virtual void mousePressEvent(QMouseEvent *);
virtual void mouseReleaseEvent(QMouseEvent *);
signals:
void pressed(QFrameExtended *);
void released(QFrameExtended *);
};
#endif
In .cpp:
#include "qwidget_extended.h"
#include "qframe_extended.h"
QWidgetExtended::QWidgetExtended(QWidget *parent) : QWidget(parent)
{
}
void QWidgetExtended::mousePressEvent(QMouseEvent *event) {
QFrameExtended frame;
QWidget *widget = this->childAt(event->pos());
if (widget != NULL) {
QString widgetClassName(widget->metaObject()->className());
//I don't use explicitly the string because if one day someone changes the name of the class, the compiler will output an error
QString className(frame.metaObject()->className());
if (widgetClassName == className) {
emit pressed(dynamic_cast<QFrameExtended*> (widget));
}
}
}
void QWidgetExtended::mouseReleaseEvent(QMouseEvent *event) {
QFrameExtended frame;
QWidget *widget = this->childAt(event->pos());
if (widget != NULL) {
QString widgetClassName(widget->metaObject()->className());
//I don't use explicitly the string because if one day someone changes the name of the class, the compiler will output an error
QString className(frame.metaObject()->className());
if (widgetClassName == className) {
emit released(dynamic_cast<QFrameExtended*> (widget));
}
}
}

Is it possible to rename a qt sub window?

I set up a sub windwow in the QMdiArea of my mainwindow. Then I made a QDialog in which I want the user to enter the title name for the Sub window. But I always get an error when trying to Change the windowTitle() to that variable.
Is there any way to update the windowTitle()?
moduleName.cpp
#include "stdafx.h"
#include "moduleName.h"
#include "iwb4.h"
#include <Windows.h>
#include <QtGui/QAction>
#include <qdom.h>
#include <qmdiarea.h>
#include "ui_module_name.h"
#include "ui_iwb4.h"
#include <qmdisubwindow.h>
moduleName::moduleName(QDialog *parent)
: QDialog(parent)
{
ui.setupUi(this);
show();
// connect ok button to save the module name
connect(ui.okButton, SIGNAL(pressed()), this, SLOT(okClicked()));
}
moduleName::~moduleName()
{
}
void moduleName::okClicked()
{
iwb4 iwb;
QTextDocument* tName = ui.textEdit->document();
iwb.p_name = tName->toPlainText();
moduleName::close();
iwb.name();
}
moduleName.h
#ifndef MODULENAME_H
#define MODULENAME_H
#include <QtGui/QWidget>
#include "ui_module_name.h"
class moduleName : public QDialog
{
Q_OBJECT
public:
moduleName(QDialog *parent = 0);
~moduleName();
public slots:
void okClicked();
protected:
Ui::Dialog ui;
};
#endif // MODULENAME_H
iwb4.cpp
#include "stdafx.h"
#include "iwb4.h"
#include <Windows.h>
#include "ui_iwb4.h"
#include <QtGui/QAction>
#include <qdom.h>
#include <qmdiarea.h>
#include "ui_module_name.h"
#include "moduleName.h"
#include <qmdisubwindow.h>
iwb4::iwb4(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
iwb4::showMaximized();
p_name = " ";
// new module button
connect(ui.actionNewModule, SIGNAL(triggered()), this, SLOT(makeModule()));
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
iwb4::~iwb4()
{
}
void iwb4::newModule(QString name)
{
m_file = new QFile("C:\\Users\\Hanna\\Desktop\\iwb\\Projekt\\iwb4\\iwb4\\Datenmodell\\module.xml");
m_file->open(QFile::ReadWrite | QFile::Text);
QDomDocument doc;
doc.setContent(m_file);
m_file->close();
m_dockWidget = new QDockWidget(m_parent);
m_dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea | Qt::TopDockWidgetArea);
m_dockWidget->showMaximized();
m_dockWidget->setTitleBarWidget(new QWidget());
m_pTableWidget = new QTableWidget(m_dockWidget);
m_dockWidget->setWidget(m_pTableWidget);
addDockWidget(Qt::LeftDockWidgetArea, m_dockWidget);
m_pTableWidget->setRowCount(10);
QDomElement elem = doc.documentElement();
m_pTableWidget->setColumnCount(elem.childNodes().count());
for (int i = 0; i < elem.childNodes().count(); i++)
{
QString header = elem.childNodes().at(i).toElement().attribute("Name");
m_TableHeader += header;
}
m_pTableWidget->setHorizontalHeaderLabels(m_TableHeader);
m_pTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
m_pTableWidget->verticalHeader()->setVisible(false);
m_pTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
m_pTableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
m_pTableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_pTableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_pTableWidget->setShowGrid(true);
m_pTableWidget->resizeColumnsToContents();
m_pTableWidget->resizeRowsToContents();
m_pTableWidget->setMaximumWidth(400);
m_pTableWidget->setMaximumHeight(300);
connect( m_pTableWidget, SIGNAL( cellDoubleClicked (int, int) ),
this, SLOT( cellSelected( int, int ) ) );
}
void iwb4::makeModule()
{
QString name;
name = p_name;
newModule(name);
QDockWidget *dock = m_dockWidget;
m_subWindow = ui.mdiArea->addSubWindow(dock);
ui.mdiArea->DontMaximizeSubWindowOnActivation;
dock->show();
dock->activateWindow();
// make rename option in right click menu
QMenu *menu = m_subWindow->systemMenu();
rename = new QAction(tr("Rename"),menu);
menu->addAction(rename);
connect(rename, SIGNAL(triggered()), this, SLOT(newName()));
}
void iwb4::newName()
{
moduleName* p_nameDialog = new moduleName();
}
void iwb4::name()
{
QString name = p_name;
m_subWindow->setWindowTitle(name);
}
iwb4.h
#ifndef IWB4_H
#define IWB4_H
#include <QtGui/QMainWindow>
#include "ui_iwb4.h"
class iwb4 : public QMainWindow
{
Q_OBJECT
public:
iwb4(QWidget *parent = 0, Qt::WFlags flags = 0);
~iwb4();
private:
private slots:
void makeModule();
public slots:
void newName();
public:
void newModule(QString name);
void name();
QFile* m_file;
QDockWidget* m_dockWidget;
QTableWidget* m_pTableWidget;
QMdiSubWindow* m_subWindow;
QStringList m_TableHeader;
QString p_name;
QAction *rename;
protected:
Ui::iwb4Class ui;
};
#endif // IWB4_H
Thanks for your help.
windowTitle() returns a copy, so this line is useless (you are modifying the copy only):
window->windowTitle() = name;
Instead, just use setWindowTitle directly:
window->setWindowTitle(name);
windowTitle() simply returns just another copy of the title of the window, so changing it does not change the title you want to change.
If you need to change the title, then directly use setWindowTitle(name); .
window->setWindowTitle(window->windowTitle()); is useless statement, because you set the title of window to its original title again.
void iwb4::name()
{
QString name;
name = p_name;
QMdiSubWindow* window;
window = m_subWindow;
window->windowTitle() = name;
window->setWindowTitle(window->windowTitle());
}
window->windowTitle( ) is a getter.
window->setWindowTitle( ) is a setter.
The getters job is to get you the value whereas the setters job is to update the value.
So running this will work:
void iwb4::name()
{
QString name;
name = "MyNewWindowName";
m_subWindow->setWindowTitle( name );
}
You have the same problem here:
void iwb4::makeModule()
{
QString name;
name = p_name;
newModule(name);
QDockWidget *dock = m_dockWidget;
m_subWindow = ui.mdiArea->addSubWindow(dock);
ui.mdiArea->DontMaximizeSubWindowOnActivation;
ui.mdiArea->windowTitle() = name;
ui.mdiArea->setWindowTitle(ui.mdiArea->windowTitle());
dock->show();
dock->activateWindow();
// make rename option in right click menu
QMenu *menu = m_subWindow->systemMenu();
rename = new QAction(tr("Rename"),menu);
menu->addAction(rename);
connect(rename, SIGNAL(triggered()), this, SLOT(newName()));
}
Change it to:
void iwb4::makeModule()
{
QString name;
name = p_name;
newModule(name);
QDockWidget *dock = m_dockWidget;
m_subWindow = ui.mdiArea->addSubWindow(dock);
ui.mdiArea->DontMaximizeSubWindowOnActivation;
//ui.mdiArea->windowTitle() = name; // <--
ui.mdiArea->setWindowTitle(name); // <--
dock->show();
dock->activateWindow();
// make rename option in right click menu
QMenu *menu = m_subWindow->systemMenu();
rename = new QAction(tr("Rename"),menu);
menu->addAction(rename);
connect(rename, SIGNAL(triggered()), this, SLOT(newName()));
}

Qt method call from another class?

I got two windows(two classes), one window that opens another when i click a button.
then the user inputs something into the newly opened window and then transfer that information to the first window when a button is clicked
The problem is I can't seem to send something to the second window so i can send the user input back to the main window. I read a few places that I should use Q_object but not really sure how that works
I should mention that I am new to Qt and didn't know about the designer there is in qt creator before i was way to ahead with the program.
Hope you have some ideas to how I can do this
edit1:
I should show the relevant code i have
Mainwindow.cpp
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
//alot of stuff not relevant right now creating different stuff
changeProfile= new QPushButton("ændre valgte profil",this);
profileList = new QComboBox(this);
cProfile = new CreateProfile;
connect(changeProfile,SIGNAL(clicked()),this,SLOT(ProfileChange()));
}
void MainWindow::ProfileChange()
{
file pfile(profileList->currentText().toStdString());
string tempName = pfile.read(light);
cProfile->setValue(light,tempName);
cPr
ofile->show();
}
void MainWindow::setProfileList(QString Pname_)
{
bool found = 0;
for (int i = 0;i<5;i++)
{
if (Pname_ ==profileList->itemText(i))
found = 1;
}
if (found !=1)
profileList->addItem(Pname_);
}
createProfile.cpp
CreateProfile::CreateProfile(QWidget *parent)
:QMainWindow(parent)
{
//alot of other irrelevant stuff here
saveP = new QPushButton("Save",this);
connect(saveP,SIGNAL(clicked()),this,SLOT(saveProfile()));
}
void CreateProfile::saveProfile()
{
temp = pName->text();
file pFile(temp.toStdString());
bool lights[2] = {light1->checkState(),light2->checkState()};
if (temp.length() == 0)
{
MessageBox(NULL,"Du har ikke skrevet noget navn ind\n Prov igen","Error",MB_ICONWARNING+MB_SETFOREGROUND);
}
else
{
pFile.save(lights);
//call function setProfileList
this->hide();
}
}
If that makes sence, If you need the .h file too i can show them also
I need to call setProfileList from the mainwindow in the function saveprofile(there is in createprofile window) or if there is a way i can change the combobox in the wainwindow from the createprofile window?
edit 2:
mainwindow.h
#include "createprofile.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public slots:
void ProfileChange();
//some other button clicks
public:
CreateProfile *cProfile;
void setProfileList(QString Pname_);
//other irelevant stuff
private:
// and some private members
};
createProfile.h
class CreateProfile : public QMainWindow
{
Q_OBJECT
public slots:
void saveProfile();
public:
explicit CreateProfile(QWidget *parent = 0);
~CreateProfile();
//and other stuff there isnt relevant
};
You are looking for the Qt signal-slot mechanism, namely:
class SecondWindow : public QMainWindow
{
Q_OBJECT
public:
SecondWindow(QWidget *parent = Q_NULLPTR) : QObject(Q_NULLPTR)
{
// ...
connect(secondWindowButton, SIGNAL(clicked(bool)), SLOT(handleClicked()));
// ...
}
public slots:
void SecondWindow::handleClicked()
{
// Gather information from the UI as you wish
firstWindow->foo();
}
// ...
}
or, if you have a container class for the windows, you could handle it in there, too, as follows:
connect(secondWindow->myButton, SIGNAL(clicked(bool)), SLOT(handleClicked()));
I found a very different way to do this, so I have made a QComboBox in the constructor of createProfile.cpp and then I have access to the profileList this way.

Catching QSpinBox text field mouseEvents

I have a reimplemented QDoubleSpinBox. I would like to catch mouseDoubleClickEvent to enable the user to change singleStep by way of QInputDialog::getDouble().
My problem is that when I reimplement the mouseDoubleClickEvent I only catch double clicks that occur over the arrow buttons. I actually want to ignore double clicks that occur in the arrows and only catch double clicks that occur in the text field. I have a feeling that I need to reimplement the mouseDoubleClickEvent of a child of the QDoubleSpinBox, but I'm not sure how to reimplement a child event nor how to select the correct child See my attempt at limiting to a child QRect in code: I think I need to specify which child...?
Thanks.
Edit: corrected class declaration/definition name mismatch.
MyQDoubleSpinBox.h
class MyQDoubleSpinBox : public QDoubleSpinBox
{
Q_OBJECT
public:
MyQDoubleSpinBox(QString str, QWidget *parent = 0);
~MyQDoubleSpinBox();
public slots:
void setStepSize(double step);
private:
double stepSize;
QString name;
protected:
void mouseDoubleClickEvent(QMouseEvent *e);
};
MyQDoubleSpinBox.cpp
#include "MyQDoubleSpinBox.h"
MyQDoubleSpinBox::MyQDoubleSpinBox(QString str, QWidget *parent)
: QDoubleSpinBox(parent), stepSize(1.00), name(str)
{
this->setMinimumWidth(150);
this->setSingleStep(stepSize);
this->setMinimum(0.0);
this->setMaximum(100.0);
}
MyQDoubleSpinBox::~MyQDoubleSpinBox()
{
}
void MyQDoubleSpinBox::setStepSize(double step)
{
this->setSingleStep(step);
}
void MyQDoubleSpinBox::mouseDoubleClickEvent(QMouseEvent *e)
{
if( this->childrenRect().contains(e->pos()) )
{
bool ok;
double d = QInputDialog::getDouble(this,
name,
tr("Step Size:"),
this->singleStep(),
0.0,
1000.0,
2,
&ok);
if(ok)
this->setSingleStep(d);
}
}
A bit of the hack getting ref to child, but it works =)
MyQDoubleSpinBox.h:
class MyQDoubleSpinBox : public QDoubleSpinBox
{
Q_OBJECT
public:
MyQDoubleSpinBox(QString str, QWidget *parent = 0);
~MyQDoubleSpinBox();
public slots:
void setStepSize(double step);
private:
double stepSize;
QString name;
protected:
bool eventFilter(QObject *, QEvent *e);
};
MyQDoubleSpinBox.cpp
MyQDoubleSpinBox::MyQDoubleSpinBox(QString str, QWidget *parent)
: QDoubleSpinBox(parent), stepSize(1.00), name(str)
{
this->setMinimumWidth(150);
this->setSingleStep(stepSize);
this->setMinimum(0.0);
this->setMaximum(100.0);
QLineEdit *editor = this->findChild<QLineEdit *>("qt_spinbox_lineedit");
editor->installEventFilter(this);
}
MyQDoubleSpinBox::~MyQDoubleSpinBox()
{
}
void MyQDoubleSpinBox::setStepSize(double step)
{
this->setSingleStep(step);
}
bool MyQDoubleSpinBox::eventFilter(QObject *, QEvent *e)
{
if (e->type() == QMouseEvent::MouseButtonDblClick)
{ bool ok;
double d = QInputDialog::getDouble(this,
name,
tr("Step Size:"),
this->singleStep(),
0.0,
1000.0,
2,
&ok);
if(ok)
this->setSingleStep(d);
}
return false;
}
Instead of overwriting events, i got ref to underlying QLineEdit and assigned event filter to it. In event filter catch only mouse double click.
You have direct access to QLineEdit using this->lineEdit()
MyQDoubleSpinBox::MyQDoubleSpinBox(QString str, QWidget *parent)
: QDoubleSpinBox(parent), stepSize(1.00), name(str)
{
this->setMinimumWidth(150);
this->setSingleStep(stepSize);
this->setMinimum(0.0);
this->setMaximum(100.0);
QLineEdit *editor = this->lineEdit(); // change here
editor->installEventFilter(this);
}