Results 1 to 3 of 3

Thread: keypressed function?

  1. #1
    Join Date
    Jan 2008
    Posts
    91
    Thanks
    8

    Default keypressed function?

    Hi every body , i try to learn qkeypressed function, if somebody any keypress my program try to detect it. But I think i made a mistake. Can you help me?

    (main.h)

    Qt Code:
    1. #include "ui_main.h"
    2. #include "dialog1.h"
    3. #include <QTranslator>
    4. #include <QKeyEvent>
    5. #include <QObject>
    6.  
    7. class MainWindow : public QMainWindow, public Ui::MainWindow
    8. {
    9. Q_OBJECT
    10. public:
    11.  
    12. int i;
    13. QTranslator translator;
    14. MainWindow(QWidget *parent = 0);
    15. ~MainWindow();
    16.  
    17.  
    18. private:
    19. Ui::MainWindow ui;
    20.  
    21.  
    22. void languageChange(int);
    23.  
    24. protected:
    25. void changeEvent(QEvent* event);
    26. void keyPressed(QKeyEvent* event);
    27. public slots:
    28. void english();
    29. void turkce();
    30. void deutsch();
    31. void reset();
    32. void sayfa();
    33. };
    To copy to clipboard, switch view to plain text mode 

    from cpp file

    Qt Code:
    1. void MainWindow::keyPressed(QKeyEvent* event)
    2. {
    3. ui.label_2->setText(QString("*"));
    4.  
    5. }
    To copy to clipboard, switch view to plain text mode 
    but it doent show me a " * " on my label_2
    Last edited by wysota; 17th January 2008 at 12:28. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: keypressed function?

    it should be
    Qt Code:
    1. void keyPressEvent(QKeyEvent *e)
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2008
    Posts
    91
    Thanks
    8

    Default Re: keypressed function?

    Thanks, it works

Similar Threads

  1. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  2. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  5. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.