Results 1 to 3 of 3

Thread: QTextDocument removing resources?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTextDocument removing resources?

    Qt Code:
    1. QTextDocument* myTextDoc = myTextBrowser->document();
    2. myTextDoc->addResource(QTextDocument::ImageResource,QUrl("relatedImage.jpg"),QVariant(relatedImg));
    To copy to clipboard, switch view to plain text mode 

    I'm trying to show a QPixmap in a QTextBrowser. I add the QPixmap relatedImg as a resource of the QTextDocument. Then I call QTextBrowser::setHtml("<img src='relatedImage.jpg'/>") to show it.

    It works. But here're some questions.
    1. Does QVariant(relatedImg) makes a full copy of the relatedImg?
    2. How can I remove that resource when I don't need to show it anymore?
    3. If relatedImg is updated (its content changed), do I need to call
    Qt Code:
    1. myTextDoc->addResource(QTextDocument::ImageResource,QUrl("relatedImage.jpg"),QVariant(relatedImg));
    To copy to clipboard, switch view to plain text mode 
    again?
    It's not the goodbye that hurts,but the flashback that follow.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTextDocument removing resources?

    Quote Originally Posted by MorrisLiang View Post
    1. Does QVariant(relatedImg) makes a full copy of the relatedImg?
    Yes. (...but no, since QPixmap uses Implicit Sharing. It will be copied if you alter the pixmap.)
    2. How can I remove that resource when I don't need to show it anymore?
    I guess by setting an emtpy QValue.
    3. If relatedImg is updated (its content changed), do I need to call
    Qt Code:
    1. myTextDoc->addResource(QTextDocument::ImageResource,QUrl("relatedImage.jpg"),QVariant(relatedImg));
    To copy to clipboard, switch view to plain text mode 
    again?
    Guess so. Try it.

  3. The following user says thank you to Lykurg for this useful post:

    MorrisLiang (9th October 2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextDocument removing resources?

    Thanks for the reply~
    It's not the goodbye that hurts,but the flashback that follow.

Similar Threads

  1. Is it possible to add QT resources to a DLL?
    By cboles in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2017, 00:12
  2. XORG using a lot of CPU resources
    By eduluz in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2010, 18:36
  3. Qt Resources
    By kaushal_gaurav in forum Qt Programming
    Replies: 3
    Last Post: 3rd October 2008, 16:30
  4. QTextDocument resources
    By xgoan in forum Qt Programming
    Replies: 1
    Last Post: 19th November 2006, 10:18
  5. i need pyqt resources
    By slhtn in forum Newbie
    Replies: 2
    Last Post: 13th August 2006, 18:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.