virtual numpad for qt4.8
-
Hello,
I am using Qt4.8 .
I wanted to use a virtual keypad for lineedits. (Numpad pops up when u click lineedits). Can be a normal keyboard as well.
Is there any exisiting project I can use or should I reinvent the wheel ?Regards,
Sandeep -
Hello,
I am using Qt4.8 .
I wanted to use a virtual keypad for lineedits. (Numpad pops up when u click lineedits). Can be a normal keyboard as well.
Is there any exisiting project I can use or should I reinvent the wheel ?Regards,
Sandeep@sandycoolxyz said in virtual numpad for qt4.8:
should I reinvent the wheel ?
Not a huge wheel to reinvent as long as you are willing to stick to Arab numbers.
#include <QWidget> #include <QGridLayout> #include <QLocale> #include <QSignalMapper> #include <QPushButton> class NumPad : public QWidget{ Q_OBJECT Q_DISABLE_COPY(NumPad) public: explicit NumPad(QWidget* parent=0) :QWidget(parent) { setWindowTitle(tr("Numpad")); QGridLayout* mainLay=new QGridLayout(this); QSignalMapper* mainMapper = new QSignalMapper(this); connect(mainMapper,SIGNAL(mapped(int)),this,SIGNAL(numKeyPressed(int))); QPushButton* zeroButton =new QPushButton(locale().toString(0),this); mainLay->addWidget(zeroButton,3,1); mainMapper->setMapping(zeroButton,0); connect(zeroButton,SIGNAL(clicked()),mainMapper,SLOT(map())); mainLay->addItem(new QSpacerItem(1,1),3,0); mainLay->addItem(new QSpacerItem(1,1),3,2); for(int i=1;i<=9;++i){ QPushButton* singleButton =new QPushButton(locale().toString(i),this); mainLay->addWidget(singleButton,(i-1)/3,(i-1)%3); mainMapper->setMapping(singleButton,i); connect(singleButton,SIGNAL(clicked()),mainMapper,SLOT(map())); } } Q_SIGNAL void numKeyPressed(int val); };
-
Hi
Nice poor mans version. :)
There is also
http://doc.qt.io/qt-4.8/qt-tools-inputpanel-example.html
Using RequestSoftwareInputPanel event.
I assume the Qt keyboard uses these ?