Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Want to change selected text's font put I can't
Qt 6.11 is out! See what's new in the release blog

Want to change selected text's font put I can't

Scheduled Pinned Locked Moved General and Desktop
14 Posts 4 Posters 6.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    przemub
    wrote on last edited by
    #4

    C'mon, man! There is google for these things! http://en.wikipedia.org/wiki/Workaround

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #5

      try this (not actively tried though):
      @
      QTextCursor cursor = textEdit->textCursor();
      QFont boldFont(textEdit->font());
      boldFont.setBold(true);
      QTextCharFormat format;
      format.setFont(boldFont);
      cursor.setBlockCharFormat(format);
      @

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tucnak
        wrote on last edited by
        #6

        [quote author="raven-worx" date="1367475346"]try this (not actively tried though):
        @
        QTextCursor cursor = textEdit->textCursor();
        QFont boldFont(textEdit->font());
        boldFont.setBold(true);
        QTextCharFormat format;
        format.setFont(boldFont);
        cursor.setBlockCharFormat(format);
        @[/quote]

        It's not enough though :) Final code is going to be:
        @
        QTextCursor cursor = textEdit->textCursor();
        QFont boldFont(textEdit->font());
        boldFont.setBold(true);
        QTextCharFormat format;
        format.setFont(boldFont);
        cursor.setBlockCharFormat(format);
        textEdit->setCursor(cursor); // maybe &cursor :)
        @

        1 Reply Last reply
        0
        • A Offline
          A Offline
          amir734jj
          wrote on last edited by
          #7

          Getting this error

          D:\qt\CS_337_Final_Project\mainwindow.cpp:116: error: C2664: 'QWidget::setCursor' : cannot convert parameter 1 from 'QTextCursor *' to 'const QCursor &'
          Reason: cannot convert from 'QTextCursor *' to 'const QCursor'
          No constructor could take the source type, or constructor overload resolution was ambiguous

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tucnak
            wrote on last edited by
            #8

            [quote author="amir734jj" date="1367547168"]Getting this error

            D:\qt\CS_337_Final_Project\mainwindow.cpp:116: error: C2664: 'QWidget::setCursor' : cannot convert parameter 1 from 'QTextCursor *' to 'const QCursor &'
            Reason: cannot convert from 'QTextCursor *' to 'const QCursor'
            No constructor could take the source type, or constructor overload resolution was ambiguous[/quote]

            Sorry, use this one instead: http://qt-project.org/doc/qt-4.8/qtextedit.html#setTextCursor

            And why can't people not copy-paste but think, think a bit?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              amir734jj
              wrote on last edited by
              #9

              Man !!

              Today Is exactly the fourth day I am using qt for first time in my life !!!

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tucnak
                wrote on last edited by
                #10

                [quote author="amir734jj" date="1367547460"]Man !!

                Today Is exactly the fourth day I am using qt for first time in my life !!!

                [/quote]

                Man !!

                Today Is exactly the 100th day I am hearing this words from people on devnet in my life !!!

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  amir734jj
                  wrote on last edited by
                  #11

                  Man ...

                  it wasn't a joke.I am just a sophomore in CS (18.5 years old !!! ) who knows only java and c/c++ !!!

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    tucnak
                    wrote on last edited by
                    #12

                    [quote author="amir734jj" date="1367547747"]Man ...

                    it wasn't a joke.I am just a sophomore in CS (18.5 years old !!! ) who knows only java and c/c++ !!!
                    [/quote]

                    Okay, guy. I know C++, don't know Java. I am 14 years old. I know how to use reference documentation.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      amir734jj
                      wrote on last edited by
                      #13

                      FYI ... it didn't work !

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        amir734jj
                        wrote on last edited by
                        #14

                        Ok , Thanks man

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved