PDA

View Full Version : Qt bug?



Hz
23rd March 2006, 09:28
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???

high_flyer
23rd March 2006, 09:31
it could be you mean Qt::Key_Return and not Key_Eneter

Hz
23rd March 2006, 09:33
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

high_flyer
23rd March 2006, 09:48
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

wysota
23rd March 2006, 09:52
Return is the big key above Shift labeled "Enter". Enter is the key on the numeric keypad.

Hz
23rd March 2006, 10:50
Ha-ha -- very funny
i am serious
i think problem in my old OS (red hat 6)

zlatko
23rd March 2006, 10:54
:D i think that problem in your keyboard

p.s. you havent understand previous answers

Hz
23rd March 2006, 10:58
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 )

jpn
23rd March 2006, 11:17
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..?


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

wysota
23rd March 2006, 11:19
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 :)

Hz
23rd March 2006, 11:24
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

zlatko
23rd March 2006, 11:26
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 :D :D :D

wysota
23rd March 2006, 11:26
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.

Hz
23rd March 2006, 11:28
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

zlatko
23rd March 2006, 11:29
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"

wysota
23rd March 2006, 11:42
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.

Hz
23rd March 2006, 11:44
thanx for program
-- i have no Enter key
2 return key on my keyboard

wysota
23rd March 2006, 11:47
...and they are both labeled "Enter". ;) You might have a broken xkbd (or whatever it is called) configuration and Enter gets remapped to Return.

Hz
23rd March 2006, 12:00
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

wysota
23rd March 2006, 12:05
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...).