Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 1645

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qabstracttextdocumentlayout.cpp -->
  <title>QTextObjectInterface Class | Qt GUI 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QTextObjectInterface</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QTextObjectInterface Class</h1>
<!-- $$$QTextObjectInterface-brief -->
<p>The <a href="qtextobjectinterface.html">QTextObjectInterface</a> class allows drawing of custom text objects in <a href="qtextdocument.html">QTextDocument</a>s. <a href="#details">More...</a></p>
<!-- @@@QTextObjectInterface -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QTextObjectInterface&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 4.5</td></tr></table></div><ul>
<li><a href="qtextobjectinterface-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qtextobjectinterface.html#dtor.QTextObjectInterface">~QTextObjectInterface</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qtextobjectinterface.html#drawObject">drawObject</a></b>(QPainter *<i>painter</i>, const QRectF &amp;<i>rect</i>, QTextDocument *<i>doc</i>, int <i>posInDocument</i>, const QTextFormat &amp;<i>format</i>) = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QSizeF </td><td class="memItemRight bottomAlign"><b><a href="qtextobjectinterface.html#intrinsicSize">intrinsicSize</a></b>(QTextDocument *<i>doc</i>, int <i>posInDocument</i>, const QTextFormat &amp;<i>format</i>) = 0</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QTextObjectInterface-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qtextobjectinterface.html">QTextObjectInterface</a> class allows drawing of custom text objects in <a href="qtextdocument.html">QTextDocument</a>s.</p>
<p>A text object describes the structure of one or more elements in a text document; for instance, images imported from HTML are implemented using text objects. A text object knows how to lay out and draw its elements when a document is being rendered.</p>
<p>Qt allows custom text objects to be inserted into a document by registering a custom <a href="qtextformat.html#objectType">object type</a> with <a href="qtextcharformat.html">QTextCharFormat</a>. A <a href="qtextobjectinterface.html">QTextObjectInterface</a> must also be implemented for this type and be <a href="qabstracttextdocumentlayout.html#registerHandler">registered</a> with the <a href="qabstracttextdocumentlayout.html">QAbstractTextDocumentLayout</a> of the document. When the object type is encountered while rendering a <a href="qtextdocument.html">QTextDocument</a>, the <a href="qtextobjectinterface.html#intrinsicSize">intrinsicSize</a>() and <a href="qtextobjectinterface.html#drawObject">drawObject</a>() functions of the interface are called.</p>
<p>The following list explains the required steps of inserting a custom text object into a document:</p>
<ul>
<li>Choose an <i>objectType</i>. The <i>objectType</i> is an integer with a value greater or equal to <a href="qtextformat.html#ObjectTypes-enum">QTextFormat::UserObject</a>.</li>
<li>Create a <a href="qtextcharformat.html">QTextCharFormat</a> object and set the object type to the chosen type using the setObjectType() function.</li>
<li>Implement the <a href="qtextobjectinterface.html">QTextObjectInterface</a> class.</li>
<li>Call <a href="qabstracttextdocumentlayout.html#registerHandler">QAbstractTextDocumentLayout::registerHandler</a>() with an instance of your <a href="qtextobjectinterface.html">QTextObjectInterface</a> subclass to register your object type.</li>
<li>Insert <a href="../qtcore/qchar.html#SpecialCharacter-enum">QChar::ObjectReplacementCharacter</a> with the aforementioned <a href="qtextcharformat.html">QTextCharFormat</a> of the chosen object type into the document. As mentioned, the functions of <a href="qtextobjectinterface.html">QTextObjectInterface</a> <a href="qtextobjectinterface.html#intrinsicSize">intrinsicSize()</a> and <a href="qtextobjectinterface.html#drawObject">drawObject()</a> will then be called with the <a href="qtextformat.html">QTextFormat</a> as parameter whenever the replacement character is encountered.</li>
</ul>
<p>A class implementing a text object needs to inherit both <a href="../qtcore/qobject.html">QObject</a> and <a href="qtextobjectinterface.html">QTextObjectInterface</a>. <a href="../qtcore/qobject.html">QObject</a> must be the first class inherited. For instance:</p>
<pre class="cpp">

  <span class="keyword">class</span> SvgTextObject : <span class="keyword">public</span> <span class="type"><a href="../qtcore/qobject.html">QObject</a></span><span class="operator">,</span> <span class="keyword">public</span> <span class="type"><a href="qtextobjectinterface.html">QTextObjectInterface</a></span>
  {
      Q_OBJECT
      Q_INTERFACES(<span class="type"><a href="qtextobjectinterface.html">QTextObjectInterface</a></span>)

</pre>
<p>The data of a text object is usually stored in the <a href="qtextcharformat.html">QTextCharFormat</a> using <a href="qtextformat.html#setProperty">QTextCharFormat::setProperty</a>(), and then retrieved with <a href="qtextformat.html#property">QTextCharFormat::property</a>().</p>
<p><b>Warning:</b> Copy and Paste operations ignore custom text objects.</p>
</div>
<p><b>See also </b>Text Object Example, <a href="qtextcharformat.html">QTextCharFormat</a>, and <a href="qtextlayout.html">QTextLayout</a>.</p>
<!-- @@@QTextObjectInterface -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$~QTextObjectInterface[overload1]$$$~QTextObjectInterface -->
<h3 class="fn" id="dtor.QTextObjectInterface"><a name="dtor.QTextObjectInterface"></a><code>[virtual] </code>QTextObjectInterface::<span class="name">~QTextObjectInterface</span>()</h3>
<p>Destroys this <a href="qtextobjectinterface.html">QTextObjectInterface</a>.</p>
<!-- @@@~QTextObjectInterface -->
<!-- $$$drawObject[overload1]$$$drawObjectQPainter*constQRectF&QTextDocument*intconstQTextFormat& -->
<h3 class="fn" id="drawObject"><a name="drawObject"></a><code>[pure virtual] </code><span class="type">void</span> QTextObjectInterface::<span class="name">drawObject</span>(<span class="type"><a href="qpainter.html">QPainter</a></span> *<i>painter</i>, const <span class="type"><a href="../qtcore/qrectf.html">QRectF</a></span> &amp;<i>rect</i>, <span class="type"><a href="qtextdocument.html">QTextDocument</a></span> *<i>doc</i>, <span class="type">int</span> <i>posInDocument</i>, const <span class="type"><a href="qtextformat.html">QTextFormat</a></span> &amp;<i>format</i>)</h3>
<p>Draws this text object using the specified <i>painter</i>.</p>
<p>The size of the rectangle, <i>rect</i>, to draw in is the size previously calculated by <a href="qtextobjectinterface.html#intrinsicSize">intrinsicSize</a>(). The rectangles position is relative to the <i>painter</i>.</p>
<p>You also get the document (<i>doc</i>) and the position (<i>posInDocument</i>) of the <i>format</i> in that document.</p>
<p><b>See also </b><a href="qtextobjectinterface.html#intrinsicSize">intrinsicSize</a>().</p>
<!-- @@@drawObject -->
<!-- $$$intrinsicSize[overload1]$$$intrinsicSizeQTextDocument*intconstQTextFormat& -->
<h3 class="fn" id="intrinsicSize"><a name="intrinsicSize"></a><code>[pure virtual] </code><span class="type"><a href="../qtcore/qsizef.html">QSizeF</a></span> QTextObjectInterface::<span class="name">intrinsicSize</span>(<span class="type"><a href="qtextdocument.html">QTextDocument</a></span> *<i>doc</i>, <span class="type">int</span> <i>posInDocument</i>, const <span class="type"><a href="qtextformat.html">QTextFormat</a></span> &amp;<i>format</i>)</h3>
<p>The intrinsicSize() function returns the size of the text object represented by <i>format</i> in the given document (<i>doc</i>) at the given position (<i>posInDocument</i>).</p>
<p>The size calculated will be used for subsequent calls to <a href="qtextobjectinterface.html#drawObject">drawObject</a>() for this <i>format</i>.</p>
<p><b>See also </b><a href="qtextobjectinterface.html#drawObject">drawObject</a>().</p>
<!-- @@@intrinsicSize -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>