Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. virtual numpad for qt4.8
Forum Updated to NodeBB v4.3 + New Features

virtual numpad for qt4.8

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 3 Posters 3.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sandycoolxyz
    wrote on last edited by
    #1

    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

    VRoninV 1 Reply Last reply
    0
    • S sandycoolxyz

      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

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @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);
      };
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      3
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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 ?

        1 Reply Last reply
        3

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved