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










6















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:



enter image description here



Is there any way to disable that blinking cursor?
thanks a lot!










share|improve this question









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.
























    6















    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:



    enter image description here



    Is there any way to disable that blinking cursor?
    thanks a lot!










    share|improve this question









    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.






















      6












      6








      6


      1






      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:



      enter image description here



      Is there any way to disable that blinking cursor?
      thanks a lot!










      share|improve this question









      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:



      enter image description here



      Is there any way to disable that blinking cursor?
      thanks a lot!







      c++ qt qtextedit






      share|improve this question









      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.











      share|improve this question









      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.









      share|improve this question




      share|improve this question








      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.






















          2 Answers
          2






          active

          oldest

          votes


















          2














          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.






          share|improve this answer
































            1














            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();






            share|improve this answer






















              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.









              draft saved

              draft discarded


















              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









              2














              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.






              share|improve this answer





























                2














                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.






                share|improve this answer



























                  2












                  2








                  2







                  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.






                  share|improve this answer















                  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.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 5 hours ago

























                  answered 5 hours ago









                  NejatNejat

                  22.8k106597




                  22.8k106597























                      1














                      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();






                      share|improve this answer



























                        1














                        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();






                        share|improve this answer

























                          1












                          1








                          1







                          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();






                          share|improve this answer













                          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();







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 5 hours ago









                          eyllanesceyllanesc

                          81k103259




                          81k103259




















                              tako is a new contributor. Be nice, and check out our Code of Conduct.









                              draft saved

                              draft discarded


















                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              Popular posts from this blog

                              How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

                              Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                              List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229