How to create a caret in a widget which has no inputbox?
I want to crearte a caret in a specific widget which has no inputbox? Could you help me?
At present, I created a class called QMyCaret subcalssed from QObject, drawed a line and then use a timer to control it to show or hide.
But I think it can't be the right solution, because there's a function called "CreateCaret" in the Win32 API.
Re: How to create a caret in a widget which has no inputbox?
Maybe it's better to use standard QLineEdit/QTextEdit and style it to whatever your want?
Re: How to create a caret in a widget which has no inputbox?
Thanks for your reply. You mean there's no convenient way to solve the problem? eh, OK. I think I should make the background transparent.
In addition, if I want to get the Asian Charactor using a local input software, what should I do? In the function "keyPressEvent" and get it by the event->key()? But it doesn't work so well.
Re: How to create a caret in a widget which has no inputbox?
Maybe I misuderstood your question, but Qt can handle Asian characters without problems, so you can simply work with QString.
Re: How to create a caret in a widget which has no inputbox?
Quote:
Originally Posted by
Michael_BJFU
QMyCaret subcalssed from QObject
are you sure? I hope you made a typo here and you meant QWidget instead of QObject.
1 Attachment(s)
Re: How to create a caret in a widget which has no inputbox?
I think I should make the question clear.
Now,in the keyPressEvent( QKeyEvent * event ), I can get only one value of specific key by event->key() such as 'a' or 'b';
But from the picture, we can see before we press down the specific number on keyborad('ç§’' is 1), the keyPressEvent() function will not be called.
Then, after I kick the number, I can't catch the event either.
Attachment 7099
Added after 17 minutes:
Quote:
Originally Posted by
nish
are you sure? I hope you made a typo here and you meant QWidget instead of QObject.
Yes, you are right. Thanks for your attention.