Now ,there is a widget (or qgraphicswidget ),is there some ways to check whether the widget is text-editable ???Thanks !
Now ,there is a widget (or qgraphicswidget ),is there some ways to check whether the widget is text-editable ???Thanks !
You can use dynamic cast to check if the widget belongs to any of the text editable widgets like QLineEdit, QTextEdit , etc.
Hope this helps
Yes, they tend to have focus. That's why I asked if you wanted to know whether some widget is a text widget at all or does it currently accept text. The latter can be checked by checking the focus, the former is basically not possible.
No, if a widget has keyboard focus, it accepts key events. That's the exact definition of focus.
e.g. buttons can get focus but aren't text-editable - perhaps that is the distinction the OP is trying to capture.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
You can tell a QLineEdit from a QPushButton in the manner that aamer4yu gave you in the first response.
Qt Code:
if (qobject_cast<QLineEdit*>(b)) qDebug() << "b is-a QLineEdit"; if (qobject_cast<QLineEdit*>(e)) qDebug() << "e is-a QLineEdit"; if (qobject_cast<QLineEdit*>(m)) qDebug() << "m is-a QLineEdit"; if (qobject_cast<QLineEdit*>(t)) qDebug() << "t is-a QLineEdit";To copy to clipboard, switch view to plain text mode
Actually, the real question is why you want to do this? What are you trying to achieve?
Why don't you just provide an input method plugin (see QInputContextPlugin and family)?
Bookmarks