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. Simply creating a document in colour
QtWS25 Last Chance

Simply creating a document in colour

Scheduled Pinned Locked Moved General and Desktop
14 Posts 4 Posters 5.2k Views
  • 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.
  • A Offline
    A Offline
    andre
    wrote on last edited by
    #5

    You can use QTextDocumentWriter to output a QTextDocument to a supported format.

    Unfortunately, QTextDocument does not support RTF as an output format. Only plain text, HTML and ODF are supported. I did not find an easy way to add support for a format either, though I might have just overlooked this in the documentation. The API design seems to have been done in a way that this should be possible though.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      crispylx
      wrote on last edited by
      #6

      Andre - Just to confirm, I can have coloured text in an ODF text document?

      I’ll try at that, any examples would be a fantastic help

      Thanks

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

        Yes, ODF supports colored text. I am, however, not 100% positive that QTextDocumentWriter supports that feature of ODF, but that would be a simple test to make yourself, would it not?

        The documentation of QTextDocumentWriter is quite clear, and the interface quite simple, I think. Is there anything in there you don't understand specifically?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          crispylx
          wrote on last edited by
          #8

          Unfortunately, I’m at the really basic level. C++ I’m ok with but I’m not experienced with Qt. You need to treat me like an idiot I’m afraid. I’ve found the example from Nokia - creating a phone bill - which I’m working through.

          Thanks for your replies

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

            Don't hesitate to ask specific questions if you stumble on problems working through the example.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #10

              I just had a look at the code of QTextEdit which (per documentation) also accepts RichText format, built only for user input (drag and drop, copy/paste) :-(

              SO I'm afraid, only plaintext, odf or html is possible (without extra coding)

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vcsala
                wrote on last edited by
                #11

                As the QTextDocument support HTML I am just wondering why do not you use it as your output format? As I understand your request most probably it can fit to your requirements.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #12

                  [quote author="Gerolf" date="1301914256"]I just had a look at the code of QTextEdit which (per documentation) also accepts RichText format, built only for user input (drag and drop, copy/paste) :-(

                  SO I'm afraid, only plaintext, odf or html is possible (without extra coding)[/quote]
                  That might actually warrant a feature request: add RTF to the list of supported formats for QTextDocumentWriter, and make it possible to add custom formats for that.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giesbert
                    wrote on last edited by
                    #13

                    Feel free to create a suggestion to Jira or make a code submission :-)
                    It would be a nice feature to have QTextDocumentWriter (or QTextDocument) plug-ins to be extendable here.

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

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

                      OK, fair enough:

                      • "Make list of supported QTextDocumentWriter formats extendible":http://bugreports.qt.nokia.com/browse/QTBUG-18570
                      • "Add support for RTF to QTextDocumentWriter":http://bugreports.qt.nokia.com/browse/QTBUG-18571
                      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