How to disable the cursor in QTextEdit?2019 Community Moderator ElectionHow do you set, clear, and toggle a single bit?How do I iterate over the words of a string?Image Processing: Algorithm Improvement for 'Coca-Cola Can' RecognitionControlling keyboard position in QTextEditqtextedit change fontQTextEdit and cursor interactionReplacing a 32-bit loop counter with 64-bit introduces crazy performance deviationsDisplay a cursor on QTextEdit in QT4.8.5The proper relationship between a text cursor and a QTextEdit widget?Get wrapped lines of QTextEdit
who is NityA Devi Goddess
Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?
Highlight parts in a screenshot
Is there a frame of reference in which I was born before I was conceived?
How can I handle a player who pre-plans arguments about my rulings on RAW?
Levi-Civita symbol: 3D matrix
Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?
How to use math.log10() function on whole pandas dataframe
Why do phishing e-mails use faked e-mail addresses instead of the real one?
What does each site of a vanilla 9.1 installation do?
Sometimes a banana is just a banana
Why would the IRS ask for birth certificates or even audit a small tax return?
Citing contemporaneous (interlaced?) preprints
Giving a talk in my old university, how prominently should I tell students my salary?
Why can't we make a perpetual motion machine by using a magnet to pull up a piece of metal, then letting it fall back down?
Is divide-by-zero a security vulnerability?
Is there any relevance to Thor getting his hair cut other than comedic value?
1970s scifi/horror novel where protagonist is used by a crablike creature to feed its larvae, goes mad, and is defeated by retraumatising him
Is there a math equivalent to the conditional ternary operator?
How to substitute values from a list into a function?
How to mitigate "bandwagon attacking" from players?
Where is the fallacy here?
When was drinking water recognized as crucial in marathon running?
How to fix my table, centering of columns
How to disable the cursor in QTextEdit?
2019 Community Moderator ElectionHow do you set, clear, and toggle a single bit?How do I iterate over the words of a string?Image Processing: Algorithm Improvement for 'Coca-Cola Can' RecognitionControlling keyboard position in QTextEditqtextedit change fontQTextEdit and cursor interactionReplacing a 32-bit loop counter with 64-bit introduces crazy performance deviationsDisplay a cursor on QTextEdit in QT4.8.5The proper relationship between a text cursor and a QTextEdit widget?Get wrapped lines of QTextEdit
I am now using QTextEdit with qt virtual keyboard, and I face an issue with QTextEdit
I want to disable the textcursor in QTextEdit. I tried to use
setCursorWidth(0);
The textcursor does disappear. But when I use arabic keybaord, there will be a small arrow blinking up there
like this:

Is there any way to disable that blinking cursor?
thanks a lot!
c++ qt qtextedit
New contributor
tako is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I am now using QTextEdit with qt virtual keyboard, and I face an issue with QTextEdit
I want to disable the textcursor in QTextEdit. I tried to use
setCursorWidth(0);
The textcursor does disappear. But when I use arabic keybaord, there will be a small arrow blinking up there
like this:

Is there any way to disable that blinking cursor?
thanks a lot!
c++ qt qtextedit
New contributor
tako is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I am now using QTextEdit with qt virtual keyboard, and I face an issue with QTextEdit
I want to disable the textcursor in QTextEdit. I tried to use
setCursorWidth(0);
The textcursor does disappear. But when I use arabic keybaord, there will be a small arrow blinking up there
like this:

Is there any way to disable that blinking cursor?
thanks a lot!
c++ qt qtextedit
New contributor
tako is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I am now using QTextEdit with qt virtual keyboard, and I face an issue with QTextEdit
I want to disable the textcursor in QTextEdit. I tried to use
setCursorWidth(0);
The textcursor does disappear. But when I use arabic keybaord, there will be a small arrow blinking up there
like this:

Is there any way to disable that blinking cursor?
thanks a lot!
c++ qt qtextedit
c++ qt qtextedit
New contributor
tako is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
tako is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 5 hours ago
eyllanesc
81k103259
81k103259
New contributor
tako is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 6 hours ago
takotako
311
311
New contributor
tako is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
tako is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
tako is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Actually this is a Qt bug which is reported here. As a workaround you can have your custom class which inherits from QTextEdit and re-implement keyPressEvent event:
class TextEdit : public QTextEdit
public:
TextEdit(QWidget* parent = nullptr) : QTextEdit(parent)
setReadOnly(true);
void keyPressEvent(QKeyEvent* event)
setReadOnly(false);
QTextEdit::keyPressEvent(event);
setReadOnly(true);
;
This will also hide the cursor in Right to left languages.
add a comment |
A simple solution is to create a QProxyStyle, so all the widgets will be affected without the need to inherit from that class.
#include <QtWidgets>
class CursorStyle: public QProxyStyle
public:
using QProxyStyle::QProxyStyle;
int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override
if(metric == PM_TextCursorWidth)
return 0;
return QProxyStyle::pixelMetric(metric, option, widget);
;
int main(int argc, char *argv[])
QApplication a(argc, argv);
CursorStyle *style = new CursorStyle(a.style());
a.setStyle(style);
QWidget w;
QVBoxLayout *lay = new QVBoxLayout(&w);
lay->addWidget(new QLineEdit);
lay->addWidget(new QTextEdit);
w.show();
return a.exec();
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
tako is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55020783%2fhow-to-disable-the-cursor-in-qtextedit%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Actually this is a Qt bug which is reported here. As a workaround you can have your custom class which inherits from QTextEdit and re-implement keyPressEvent event:
class TextEdit : public QTextEdit
public:
TextEdit(QWidget* parent = nullptr) : QTextEdit(parent)
setReadOnly(true);
void keyPressEvent(QKeyEvent* event)
setReadOnly(false);
QTextEdit::keyPressEvent(event);
setReadOnly(true);
;
This will also hide the cursor in Right to left languages.
add a comment |
Actually this is a Qt bug which is reported here. As a workaround you can have your custom class which inherits from QTextEdit and re-implement keyPressEvent event:
class TextEdit : public QTextEdit
public:
TextEdit(QWidget* parent = nullptr) : QTextEdit(parent)
setReadOnly(true);
void keyPressEvent(QKeyEvent* event)
setReadOnly(false);
QTextEdit::keyPressEvent(event);
setReadOnly(true);
;
This will also hide the cursor in Right to left languages.
add a comment |
Actually this is a Qt bug which is reported here. As a workaround you can have your custom class which inherits from QTextEdit and re-implement keyPressEvent event:
class TextEdit : public QTextEdit
public:
TextEdit(QWidget* parent = nullptr) : QTextEdit(parent)
setReadOnly(true);
void keyPressEvent(QKeyEvent* event)
setReadOnly(false);
QTextEdit::keyPressEvent(event);
setReadOnly(true);
;
This will also hide the cursor in Right to left languages.
Actually this is a Qt bug which is reported here. As a workaround you can have your custom class which inherits from QTextEdit and re-implement keyPressEvent event:
class TextEdit : public QTextEdit
public:
TextEdit(QWidget* parent = nullptr) : QTextEdit(parent)
setReadOnly(true);
void keyPressEvent(QKeyEvent* event)
setReadOnly(false);
QTextEdit::keyPressEvent(event);
setReadOnly(true);
;
This will also hide the cursor in Right to left languages.
edited 5 hours ago
answered 5 hours ago
NejatNejat
22.8k106597
22.8k106597
add a comment |
add a comment |
A simple solution is to create a QProxyStyle, so all the widgets will be affected without the need to inherit from that class.
#include <QtWidgets>
class CursorStyle: public QProxyStyle
public:
using QProxyStyle::QProxyStyle;
int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override
if(metric == PM_TextCursorWidth)
return 0;
return QProxyStyle::pixelMetric(metric, option, widget);
;
int main(int argc, char *argv[])
QApplication a(argc, argv);
CursorStyle *style = new CursorStyle(a.style());
a.setStyle(style);
QWidget w;
QVBoxLayout *lay = new QVBoxLayout(&w);
lay->addWidget(new QLineEdit);
lay->addWidget(new QTextEdit);
w.show();
return a.exec();
add a comment |
A simple solution is to create a QProxyStyle, so all the widgets will be affected without the need to inherit from that class.
#include <QtWidgets>
class CursorStyle: public QProxyStyle
public:
using QProxyStyle::QProxyStyle;
int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override
if(metric == PM_TextCursorWidth)
return 0;
return QProxyStyle::pixelMetric(metric, option, widget);
;
int main(int argc, char *argv[])
QApplication a(argc, argv);
CursorStyle *style = new CursorStyle(a.style());
a.setStyle(style);
QWidget w;
QVBoxLayout *lay = new QVBoxLayout(&w);
lay->addWidget(new QLineEdit);
lay->addWidget(new QTextEdit);
w.show();
return a.exec();
add a comment |
A simple solution is to create a QProxyStyle, so all the widgets will be affected without the need to inherit from that class.
#include <QtWidgets>
class CursorStyle: public QProxyStyle
public:
using QProxyStyle::QProxyStyle;
int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override
if(metric == PM_TextCursorWidth)
return 0;
return QProxyStyle::pixelMetric(metric, option, widget);
;
int main(int argc, char *argv[])
QApplication a(argc, argv);
CursorStyle *style = new CursorStyle(a.style());
a.setStyle(style);
QWidget w;
QVBoxLayout *lay = new QVBoxLayout(&w);
lay->addWidget(new QLineEdit);
lay->addWidget(new QTextEdit);
w.show();
return a.exec();
A simple solution is to create a QProxyStyle, so all the widgets will be affected without the need to inherit from that class.
#include <QtWidgets>
class CursorStyle: public QProxyStyle
public:
using QProxyStyle::QProxyStyle;
int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override
if(metric == PM_TextCursorWidth)
return 0;
return QProxyStyle::pixelMetric(metric, option, widget);
;
int main(int argc, char *argv[])
QApplication a(argc, argv);
CursorStyle *style = new CursorStyle(a.style());
a.setStyle(style);
QWidget w;
QVBoxLayout *lay = new QVBoxLayout(&w);
lay->addWidget(new QLineEdit);
lay->addWidget(new QTextEdit);
w.show();
return a.exec();
answered 5 hours ago
eyllanesceyllanesc
81k103259
81k103259
add a comment |
add a comment |
tako is a new contributor. Be nice, and check out our Code of Conduct.
tako is a new contributor. Be nice, and check out our Code of Conduct.
tako is a new contributor. Be nice, and check out our Code of Conduct.
tako is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55020783%2fhow-to-disable-the-cursor-in-qtextedit%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown