Results 1 to 20 of 20

Thread: Qt bug?

  1. #1
    Join Date
    Feb 2006
    Posts
    18

    Default Qt bug?

    i use Qt 4.1.1

    my code:
    void TextEdit::keyPressEvent ( QKeyEvent * event)
    {
    if (event->key() == Qt::Key_Enter)
    {
    QTextEdit::keyPressEvent(event);
    alignCurrent();
    }
    else
    QTextEdit::keyPressEvent(event);
    }

    it's not work if i press "Enter" key.
    to make it work i must write
    event->key()+1 == Qt::Key_Enter
    WHY???
    Cut and Run

  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: Qt bug?

    it could be you mean Qt::Key_Return and not Key_Eneter

  3. #3
    Join Date
    Feb 2006
    Posts
    18

    Default Re: Qt bug?

    i press key Enter i am sure
    it work if key()+1 == Qt::key_Enter what about this?

    event->key() =16777220
    Qt::key_Enter = 16777221
    Last edited by Hz; 23rd March 2006 at 09:38.
    Cut and Run

  4. #4
    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: Qt bug?

    if you get event->key() =16777220 when you press the key, the you are pressing the return key:
    16777220 (dec) => 0x01000004
    In the docs:
    Qt::Key_Return 0x01000004

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt bug?

    Return is the big key above Shift labeled "Enter". Enter is the key on the numeric keypad.

  6. #6
    Join Date
    Feb 2006
    Posts
    18

    Default Re: Qt bug?

    Ha-ha -- very funny
    i am serious
    i think problem in my old OS (red hat 6)
    Cut and Run

  7. #7
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Qt bug?

    i think that problem in your keyboard

    p.s. you havent understand previous answers
    a life without programming is like an empty bottle

  8. #8
    Join Date
    Feb 2006
    Posts
    18

    Default Re: Qt bug?

    Ooo real smart guy
    special for u:
    <-- return key
    /__| enter key (bad pic but it real big key i think u can found look like )
    \
    so i can press need key
    i still have problem and stop stupid comments
    (my" return key" = 16777219 )
    Last edited by Hz; 23rd March 2006 at 11:17.
    Cut and Run

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qt bug?

    What is your problem?
    Regardless of what reads on the buttons of your keyboard, Qt handles them the way wysota said.

    So why can't you just handle both, or only Qt::Key_Return if that's what you're after..?
    Qt Code:
    1. void TextEdit::keyPressEvent(QKeyEvent* event)
    2. {
    3. QTextEdit::keyPressEvent(event);
    4. if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
    5. {
    6. alignCurrent();
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt bug?

    These are not stupid comments, we are serious. Try changing Qt::Key_Enter to Qt::Key_Return and see if it works. The "really big key" is Return, not Enter. In whole computer world it is known as Return, just some (probably) IBM guys labeled it "Enter" on their PC keyboards and since then PC-guys (and all their keyboards) label that key "Enter". But that doesn't change the fact that it's Return. And "<--" key is backspace

  11. #11
    Join Date
    Feb 2006
    Posts
    18

    Default Re: Qt bug?

    i havn't problem to get rigth result

    i just don't understand why when i press "enter key" (big key above Shift labeled "Enter")
    it's not equal to Qt::Key_Enter

    ps my return key delete last simbol
    my enter key -- go next line
    all work correctly
    Last edited by Hz; 23rd March 2006 at 11:26.
    Cut and Run

  12. #12
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Qt bug?

    Quote Originally Posted by Hz
    Ooo real smart guy
    special for u:
    <-- return key
    /__| enter key (bad pic but it real big key i think u can found look like )
    \
    so i can press need key
    i still have problem and stop stupid comments
    (my" return key" = 16777219 )
    sorry but i cant stop spaming
    a life without programming is like an empty bottle

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt bug?

    Quote Originally Posted by Hz
    i just don't understand why when i press "enter key" (big key above Shift labeled "Enter")
    it's not equal to Qt::Key_Enter
    Because it is called RETURN! ENTER is the key on the numeric keypad. Press it and you'll see it will trigger the condition.

  14. #14
    Join Date
    Feb 2006
    Posts
    18

    Default Re: Qt bug?

    my return key delete last simbol
    my enter key -- go next line
    all work correctly

    the key on the numeric keypad it's same key
    and make same result
    Cut and Run

  15. #15
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Qt bug?

    Quote Originally Posted by Hz
    i havn't problem to get rigth result

    i just don't understand why when i press "enter key" (big key above Shift labeled "Enter")
    it's not equal to Qt::Key_Enter

    ps my return key delete last simbol
    my enter key -- go next line
    all work correctly
    ... and becouse "Enter" is positioned near "+" and "Del"
    a life without programming is like an empty bottle

  16. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt bug?

    Try the program attached. It's for Qt4 but if you use Qt3 all you have to do is to change included files and regenerate the project file. The rest should work out of the box.
    Attached Files Attached Files

  17. #17
    Join Date
    Feb 2006
    Posts
    18

    Default Re: Qt bug?

    thanx for program
    -- i have no Enter key
    2 return key on my keyboard
    Cut and Run

  18. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt bug?

    ...and they are both labeled "Enter". You might have a broken xkbd (or whatever it is called) configuration and Enter gets remapped to Return.

  19. #19
    Join Date
    Feb 2006
    Posts
    18

    Default Re: Qt bug?

    i find my old qt3 program
    and take keyboard to another computer with qt3 -- all work --- so keyboard not broken

    maybe OS configuration ... i dont know
    Cut and Run

  20. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt bug?

    The keybord (as a device) can't be broken in this way. It is purely a software issue. As I said -- probably xkbd configuration is screwed up. You could check if the situation is the same under a text console -- it has a separate configuration. There is a tool to check the scan codes (I don't remember its name -- google for it or check the consoletools package, it should be there, I guess...).

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.