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. QTextEdit with html and image export
Forum Updated to NodeBB v4.3 + New Features

QTextEdit with html and image export

Scheduled Pinned Locked Moved Solved General and Desktop
qtextedithtml exportimage exportrelative path
4 Posts 2 Posters 1.6k Views 2 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.
  • K Offline
    K Offline
    koahnig
    wrote on last edited by koahnig
    #1

    I am using QTextEdit with html for loading and displaying an html files including images. Recently added "Save as ..." fails on saving the file in a different location because the images having a relative path.

    Do I have to search and change the html with own code for detecting and adjusting the path to images or is there some better solution already in Qt?

    My searches were not successful.

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Hi Koahnig,

      Maybe this topic can help you in the right direction?

      Hope it helps,

      Eddy

      Qt Certified Specialist
      www.edalsolutions.be

      K 1 Reply Last reply
      2
      • EddyE Eddy

        Hi Koahnig,

        Maybe this topic can help you in the right direction?

        Hope it helps,

        Eddy

        K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        @Eddy

        Thanks for reply.

        Not exactly. I am trying to avoid the situation that there is already everything handled in Qt directly and I am trying to find and substitute the string without need.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          I have found a solution suiting me.

              QRegularExpression rexp ( "<img src=\\\"([^\\\"]{1,})([^/]{0,})/>" );
              QRegularExpressionMatch match;
              int pos = content.indexOf ( rexp, pos + 1 ) ;
              if ( pos > -1 )
              {
              match = rexp.match ( content, pos );
              if ( match.isValid() )
                  {
                      QString imFile = match.captured ( 1 );
                  }
              }
          

          imFile will hold the file name stored.

          Or as alternative for the deprecated QRegExp. The expression itself works for both.

              QRegExp rexp ( "<img src=\\\"([^\\\"]{1,})([^/]{0,})/>" );
              int pos = content.indexOf ( rexp );
              if ( pos >= 0)
              {
                  QString imFile = rexp.cap ( 1 );
              }
          

          Note: The indexOf with QRegularExpression may also handle the QRegularExpressionMatch since version 5.5. This would make it more compact.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          2

          • Login

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