Results 1 to 2 of 2

Thread: Something about the QKeyEvent in Qt3

  1. #1
    Join Date
    Mar 2009
    Location
    Nanjing,China
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Something about the QKeyEvent in Qt3

    My Platform is WinXp+VC6.0+Qt3.
    I rewrite the QWidget::keyPressEvent(QKeyEvent* e).
    but something wrong about it,
    if I press the key 'a',the e.key() = 65 and text is 'a',the state = 0,but the ascii is 97; OK
    if I press the key 'b',the e.key() = 66 and text is 'b',the state = 0,but the ascii is 98; OK
    if I press the key "Ctrl+a",the e.key = 65,and text().ascii()[0] = 1,the stete = 512; Err;
    if I press the key "Shift+a",the e.key = 65,and text() = 'A',the ascii = 65;OK

    so I want to know why I press the key "Ctrl+a",the text() is not 'a'?and why the key() is always equal to 65 and not equal to 97?

    thanks!

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Something about the QKeyEvent in Qt3

    so I want to know why I press the key "Ctrl+a",the text() is not 'a'?
    open up notepad.. press the key a.... u will see "a" typed on the screen.
    now press Ctrl+a... nothing will be typed... u will see selection. thats why the text is not a.

    and why the key() is always equal to 65 and not equal to 97?
    because key() returns Qt::Key_A (in Qt4... in Qt3 also if i remeber correctly). Qt::Key_A is a enum value
    which means the hardware key which can have only one value. In other words Qt::Key_A == "the first key of the second row of keyboard", and the hardware key may represent another charector in chinese.

Similar Threads

  1. QKeyEvent Gives Odd Response to SpaceBar
    By GTBuilder in forum Newbie
    Replies: 1
    Last Post: 2nd August 2008, 21:15
  2. QKeyEvent Problem
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2008, 23:36
  3. QKeyEvent
    By peace_comp in forum Qt Programming
    Replies: 2
    Last Post: 10th April 2008, 13:13
  4. what's mean of the member of QKeyEvent
    By sunote in forum Qt Programming
    Replies: 1
    Last Post: 11th November 2007, 21:25
  5. QKeyEvent questions
    By bglidden in forum Qt Programming
    Replies: 1
    Last Post: 3rd October 2006, 06:29

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.