Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. Tastenkürzel in QLineEditor Anzeigen
Forum Updated to NodeBB v4.3 + New Features

Tastenkürzel in QLineEditor Anzeigen

Scheduled Pinned Locked Moved Unsolved German
5 Posts 2 Posters 1.2k 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.
  • V Offline
    V Offline
    val78
    wrote on last edited by
    #1

    Hallo.
    Ich brauche code, für Tastenkürzel in QLineEdit..

    und zwar wenn in QlineEdit(TInPut) Tasten Drückt, soll die in QlineEdit(TInPut) anzeigen

    so wie Z.b In QT-Creater.

    danke Vorraus

    raven-worxR 1 Reply Last reply
    0
    • V val78

      Hallo.
      Ich brauche code, für Tastenkürzel in QLineEdit..

      und zwar wenn in QlineEdit(TInPut) Tasten Drückt, soll die in QlineEdit(TInPut) anzeigen

      so wie Z.b In QT-Creater.

      danke Vorraus

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @val78
      http://doc.qt.io/qt-5/qkeysequenceedit.html

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • V Offline
        V Offline
        val78
        wrote on last edited by
        #3

        ich habe das gefunden

        https://stackoverflow.com/questions/13487352/how-to-create-a-hotkey-field-in-qt

        aber kopiere nich wie das funktionieren soll.

        raven-worxR 1 Reply Last reply
        0
        • V val78

          ich habe das gefunden

          https://stackoverflow.com/questions/13487352/how-to-create-a-hotkey-field-in-qt

          aber kopiere nich wie das funktionieren soll.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @val78
          was gefällt dir an QKeysequenceEdit nicht?!
          Entspricht genau deiner Beschreibung

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • V Offline
            V Offline
            val78
            wrote on last edited by
            #5

            Ich habe ich so

            neukurz.cpp
            
            #include "neukurz.h"
            #include "ui_neukurz.h"
            
            
            NeuKurz::NeuKurz(QWidget *parent) :
                QDialog(parent),
                ui(new Ui::NeuKurz)
            {
                ui->setupUi(this);
            }
            
            
            NeuKurz::~NeuKurz()
            {
                delete ui;
            }
            
            void QLineEditHotKey::keyPressEvent( QKeyEvent * event )
            {
                int keyInt = event->key();
                Qt::Key key = static_cast<Qt::Key>(keyInt);
            
                // Handle unknown keys
                if( key == Qt::Key_unknown )
                    return;
            
                // Pressing Esc or Backspace will clear the content
                if( key == Qt::Key_Escape || key == Qt::Key_Backspace )
                {
                    setText(nullptr);
                    return;
                }
            
                // Empty means a special key like F5, Delete, Home etc
                if( event->text().isEmpty() )
                    return;
            
                // Checking for key combinations
                Qt::KeyboardModifiers modifiers = event->modifiers();
            
                if(modifiers.testFlag(Qt::NoModifier))
                    return;
                if(modifiers.testFlag(Qt::ShiftModifier))
                    keyInt += Qt::SHIFT;
                if(modifiers.testFlag(Qt::ControlModifier))
                    keyInt += Qt::CTRL;
                if(modifiers.testFlag(Qt::AltModifier))
                    keyInt += Qt::ALT;
            
                setText( QKeySequence(keyInt).toString(QKeySequence::NativeText) );
            }
            
            void NeuKurz::on_buttonBox_accepted()
            {
            
            }
            
            nuekurz.h
            
            #ifndef NEUKURZ_H
            #define NEUKURZ_H
            
            #include <QLineEdit>
            #include <QDialog>
            #include <QKeyEvent>
            
            namespace Ui {
            class NeuKurz;
            }
            
            class NeuKurz : public QDialog
            {
                Q_OBJECT
            
            public:
                explicit NeuKurz(QWidget *parent = nullptr);
                ~NeuKurz();
            
            private slots:
                void on_buttonBox_accepted();
            
            private:
                Ui::NeuKurz *ui;
            };
            
            class QLineEditHotKey: public QLineEdit
            {
            public:
                QLineEditHotKey( QWidget* pParent = nullptr);
                ~QLineEditHotKey(){}
            protected:
                void keyPressEvent ( QKeyEvent * event );
            };
            #endif // NEUKURZ_H
            
            

            aber Funktioniert nicht . zeigt auch kein fehler!

            1 Reply Last reply
            0

            • Login

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