[SOLVED] Conversion from ascci to char in QML
-
wrote on 17 Jun 2015, 06:39 last edited by Pradeep Kumar 7 May 2015, 16:07
Hello ,
I have Text Input and virtual Keyboard, i want value to be entered in text input, but im getting ascii values of (letters,numbers) in text inout when i press the letters, numbers in keyboard, so i want same letter to be entered in text input as in keyboard, ex: if i click Letter "P","p" i need to get Letter "P","p" in my text input,
so please help me guys.
-
Hello ,
I have Text Input and virtual Keyboard, i want value to be entered in text input, but im getting ascii values of (letters,numbers) in text inout when i press the letters, numbers in keyboard, so i want same letter to be entered in text input as in keyboard, ex: if i click Letter "P","p" i need to get Letter "P","p" in my text input,
so please help me guys.
Hi @Pradeep-Kumar.M,
Use String.fromCharCode to convert code to character and then use insert to add that character toTextInput
. -
Hi @Pradeep-Kumar.M,
Use String.fromCharCode to convert code to character and then use insert to add that character toTextInput
.wrote on 17 Jun 2015, 06:59 last edited byThank you it worked,,
but when i press caps lock depending on capital "P" or small "p", it has to print,
but for caps or small im getting "P" itselfmy code:
Keys.onPressed:
{if(event.key === Qt.Key_P) { console.log("zero is pressed"+String.fromCharCode(Qt.Key_P)); textin.insert(0,String.fromCharCode(Qt.Key_P)) } }
textin is id for textinput;
help me -
Thank you it worked,,
but when i press caps lock depending on capital "P" or small "p", it has to print,
but for caps or small im getting "P" itselfmy code:
Keys.onPressed:
{if(event.key === Qt.Key_P) { console.log("zero is pressed"+String.fromCharCode(Qt.Key_P)); textin.insert(0,String.fromCharCode(Qt.Key_P)) } }
textin is id for textinput;
help me -
Thank you it worked,,
but when i press caps lock depending on capital "P" or small "p", it has to print,
but for caps or small im getting "P" itselfmy code:
Keys.onPressed:
{if(event.key === Qt.Key_P) { console.log("zero is pressed"+String.fromCharCode(Qt.Key_P)); textin.insert(0,String.fromCharCode(Qt.Key_P)) } }
textin is id for textinput;
help me@Pradeep-Kumar.M That being said you don't need conversion at all. Just use
event.text
for getting exact character and then insert. Just watch out for other key press (like shift or caps lock) which you will have to ignore. -
@Pradeep-Kumar.M That being said you don't need conversion at all. Just use
event.text
for getting exact character and then insert. Just watch out for other key press (like shift or caps lock) which you will have to ignore.wrote on 17 Jun 2015, 07:34 last edited by@p3c0
Keys.onPressed:
{if(event.text) { console.log("zero is pressed"); textin.insert(0,String.fromCharCode(Keys)) } }
is this code k,
because when i press any keys its getting printed in application outputbut i need in text input.
-
@p3c0
Keys.onPressed:
{if(event.text) { console.log("zero is pressed"); textin.insert(0,String.fromCharCode(Keys)) } }
is this code k,
because when i press any keys its getting printed in application outputbut i need in text input.
@Pradeep-Kumar.M No conversion required now. Try
Keys.onPressed: { textin.insert(0,event.text) }
-
wrote on 17 Jun 2015, 07:39 last edited by
its working fine, thank u for that,
but in text input, its not appending, its getting from right to left, i want from left to right. -
its working fine, thank u for that,
but in text input, its not appending, its getting from right to left, i want from left to right.@Pradeep-Kumar.M Are you using Arabic language or Arabic locale ? In that case it will be aligned to right side.
-
@Pradeep-Kumar.M Are you using Arabic language or Arabic locale ? In that case it will be aligned to right side.
wrote on 17 Jun 2015, 07:47 last edited byno, in text input its printing, which ever key is pressed, but not in appending fashion
ex: if i press 1234567890abcdefgh
its printing in text input as hgfedcba0987654321
i want in 1234567890abcdefgh
-
no, in text input its printing, which ever key is pressed, but not in appending fashion
ex: if i press 1234567890abcdefgh
its printing in text input as hgfedcba0987654321
i want in 1234567890abcdefgh
@Pradeep-Kumar.M Ofcourse it will. You are inserting every new character at 0'th position.
-
Hi @Pradeep-Kumar.M,
Use String.fromCharCode to convert code to character and then use insert to add that character toTextInput
.wrote on 17 Jun 2015, 07:50 last edited byso what to do if i want in appending fashion of letters, numbers, any other keys from keyboard, to text input
-
so what to do if i want in appending fashion of letters, numbers, any other keys from keyboard, to text input
@Pradeep-Kumar.M Get the new index position from
TextInput
. You want it to append it at the end solength
should give you the last index. Insert it theretextin.insert(textin.length,event.text)
-
@Pradeep-Kumar.M Get the new index position from
TextInput
. You want it to append it at the end solength
should give you the last index. Insert it theretextin.insert(textin.length,event.text)
wrote on 17 Jun 2015, 07:55 last edited bythank you, it worked.
-
thank you, it worked.
@Pradeep-Kumar.M You're Welcome :)
-
wrote on 17 Jun 2015, 08:07 last edited by
one more question
i tries Qt Integration
here is ex: of main.cpp
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QObject *topLevel = engine.rootObjects().value(0);
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
window->dumpObjectTree();
QQuickWindow *window1 = topLevel->findChild<QQuickWindow * >(objectname);can i have QQMLContext, QQMLComponent & QQMLEngine,
if so
can u provide code of it, along with component item. -
one more question
i tries Qt Integration
here is ex: of main.cpp
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QObject *topLevel = engine.rootObjects().value(0);
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
window->dumpObjectTree();
QQuickWindow *window1 = topLevel->findChild<QQuickWindow * >(objectname);can i have QQMLContext, QQMLComponent & QQMLEngine,
if so
can u provide code of it, along with component item.@Pradeep-Kumar.M Do you mean an example ?
-
wrote on 17 Jun 2015, 08:12 last edited by
yeah but
to replace the lines above which i sent in previous post -
yeah but
to replace the lines above which i sent in previous post@Pradeep-Kumar.M Here's an example.
-
wrote on 17 Jun 2015, 08:17 last edited by
for wat exactly setcontextproperty is used
6/26