Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 1dd17e0d683ef79b4bb6872bbf359d7f > files > 6659

qt4-doc-4.8.7-26.2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qt4-intro.qdoc -->
  <title>Qt 4.8: What's New in Qt 4</title>
  <link rel="stylesheet" type="text/css" href="style/style.css" />
  <script src="scripts/jquery.js" type="text/javascript"></script>
  <script src="scripts/functions.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/superfish.css" />
  <link rel="stylesheet" type="text/css" href="style/narrow.css" />
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->

<script src="scripts/superfish.js" type="text/javascript"></script>
<script src="scripts/narrow.js" type="text/javascript"></script>

</head>
<body class="" onload="CheckEmptyAndLoadList();">
 <div class="header" id="qtdocheader">
    <div class="content"> 
    <div id="nav-logo">
      <a href="index.html">Home</a></div>
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
    <div id="narrowsearch"></div>
    <div id="nav-topright">
      <ul>
        <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li>
        <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li>
        <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/">
          DOC</a></li>
        <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li>
      </ul>
    </div>
    <div id="shortCut">
      <ul>
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li>
        <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS        </a></li>
      </ul>
     </div>
 <ul class="sf-menu" id="narrowmenu"> 
             <li><a href="#">API Lookup</a> 
                 <ul> 
                     <li><a href="classes.html">Class index</a></li> 
           <li><a href="functions.html">Function index</a></li> 
           <li><a href="modules.html">Modules</a></li> 
           <li><a href="namespaces.html">Namespaces</a></li> 
           <li><a href="qtglobal.html">Global Declarations</a></li> 
           <li><a href="qdeclarativeelements.html">QML elements</a></li> 
             </ul> 
             </li> 
             <li><a href="#">Qt Topics</a> 
                 <ul> 
                        <li><a href="qt-basic-concepts.html">Programming with Qt</a></li>  
                        <li><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li>  
                        <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li>  
                        <li><a href="supported-platforms.html">Supported Platforms</a></li>  
                        <li><a href="technology-apis.html">Qt and Key Technologies</a></li>  
                        <li><a href="best-practices.html">How-To's and Best Practices</a></li>  
              </ul> 
                 </li> 
                 <li><a href="#">Examples</a> 
                     <ul> 
                       <li><a href="all-examples.html">Examples</a></li> 
                       <li><a href="tutorials.html">Tutorials</a></li> 
                       <li><a href="demos.html">Demos</a></li> 
                       <li><a href="qdeclarativeexamples.html">QML Examples</a></li> 
                </ul> 
                     </li> 
                 </ul> 
    </div>
  </div>
  <div class="wrapper">
    <div class="hd">
      <span></span>
    </div>
    <div class="bd group">
      <div class="sidebar">
        <div class="searchlabel">
          Search index:</div>
        <div class="search" id="sidebarsearch">
          <form id="qtdocsearch" action="" onsubmit="return false;">
            <fieldset>
              <input type="text" name="searchstring" id="pageType" value="" />
 <div id="resultdialog"> 
 <a href="#" id="resultclose">Close</a> 
 <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> 
 <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span>&nbsp;results:</p> 
 <ul id="resultlist" class="all"> 
 </ul> 
 </div> 
            </fieldset>
          </form>
        </div>
        <div class="box first bottombar" id="lookup">
          <h2 title="API Lookup"><span></span>
            API Lookup</h2>
          <div  id="list001" class="list">
          <ul id="ul001" >
              <li class="defaultLink"><a href="classes.html">Class index</a></li>
              <li class="defaultLink"><a href="functions.html">Function index</a></li>
              <li class="defaultLink"><a href="modules.html">Modules</a></li>
              <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li>
              <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li>
              <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li>
            </ul> 
          </div>
        </div>
        <div class="box bottombar" id="topics">
          <h2 title="Qt Topics"><span></span>
            Qt Topics</h2>
          <div id="list002" class="list">
            <ul id="ul002" >
               <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> 
               <li class="defaultLink"><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li> 
               <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> 
               <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li>  
               <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> 
               <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> 
            </ul>  
          </div>
        </div>
        <div class="box" id="examples">
          <h2 title="Examples"><span></span>
            Examples</h2>
          <div id="list003" class="list">
        <ul id="ul003">
              <li class="defaultLink"><a href="all-examples.html">Examples</a></li>
              <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li>
              <li class="defaultLink"><a href="demos.html">Demos</a></li>
              <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li>
            </ul> 
          </div>
        </div>
      </div>
      <div class="wrap">
        <div class="toolbar">
          <div class="breadcrumb toolblock">
            <ul>
              <li class="first"><a href="index.html">Home</a></li>
              <!--  Breadcrumbs go here -->
<li>What's New in Qt 4</li>
            </ul>
          </div>
          <div class="toolbuttons toolblock">
            <ul>
              <li id="smallA" class="t_button">A</li>
              <li id="medA" class="t_button active">A</li>
              <li id="bigA" class="t_button">A</li>
              <li id="print" class="t_button"><a href="javascript:this.print();">
                <span>Print</span></a></li>
            </ul>
        </div>
        </div>
        <div class="content mainContent">
  <link rel="next" href="qt4-tulip.html" />
  <link rel="start" href="index.html" />
<p class="naviNextPrevious headerNavi">
<a class="nextPage" href="qt4-tulip.html">The Tulip Container Classes</a>
</p><p/>
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#new-technologies-in-qt-4">New Technologies in Qt 4</a></li>
<li class="level1"><a href="#recent-additions-to-qt-4">Recent Additions to Qt 4</a></li>
<li class="level1"><a href="#significant-improvements">Significant Improvements</a></li>
<li class="level1"><a href="#build-system">Build System</a></li>
<li class="level1"><a href="#include-syntax">Include Syntax</a></li>
<li class="level1"><a href="#namespaces">Namespaces</a></li>
<li class="level1"><a href="#qobject-qwidget-constructors">QObject/QWidget Constructors</a></li>
<li class="level1"><a href="#dynamic-casts">Dynamic Casts</a></li>
<li class="level1"><a href="#qpointer-t">QPointer&lt;T&gt;</a></li>
<li class="level1"><a href="#paint-events">Paint Events</a></li>
<li class="level1"><a href="#qt-3-support-layer">Qt 3 Support Layer</a></li>
</ul>
</div>
<h1 class="title">What's New in Qt 4</h1>
<span class="subtitle"></span>
<!-- $$$qt4-intro.html-description -->
<div class="descr"> <a name="details"></a>
<p>This document covers the most important differences between Qt 3 and Qt 4. Although it is not intended to be a comprehensive porting guide, it tells you about the most important portability issues that you may encounter. It also explains how to turn on Qt 3 compatibility support.</p>
<a name="new-technologies-in-qt-4"></a>
<h2>New Technologies in Qt 4</h2>
<p>Qt 4 introduces the following core technologies:</p>
<ul>
<li><a href="qt4-tulip.html">Tulip</a>, a new set of template container classes.</li>
<li><a href="qt4-interview.html">Interview</a>, a model/view architecture for item views.</li>
<li><a href="qt4-arthur.html">Arthur</a>, the Qt 4 painting framework.</li>
<li><a href="qt4-scribe.html">Scribe</a>, the Unicode text renderer with a public API for performing low-level text layout.</li>
<li><a href="qt4-mainwindow.html">Mainwindow</a>, a modern action-based mainwindow, toolbar, menu, and docking architecture.</li>
<li>The new <a href="qt4-designer.html"><i>Qt Designer</i></a> user interface design tool.</li>
</ul>
<a name="recent-additions-to-qt-4"></a>
<h2>Recent Additions to Qt 4</h2>
<p>The following features have been added to Qt since the first release of Qt 4.</p>
<p>In Qt 4.8:</p>
<ul>
<li><a href="qtquick.html">Qt Quick</a> 1.1 offers changes to the <a href="qdeclarativeelements.html">QML Elements</a> and performance upgrades</li>
</ul>
<p>In Qt 4.7:</p>
<ul>
<li>Declarative UI Development with <a href="qtquick.html">Qt Quick</a>, technologies for creating fluid, dynamic user interfaces.</li>
<li>Support for <a href="bearer-management.html">network bearer management</a>, enabling features such as control over network interfaces and support for roaming between networks.</li>
<li>Feature and performance improvements in <a href="qtwebkit.html">QtWebKit</a>, including a new tiled backing store, control over scroll bars used in frames and framesets, accelerated compositing and <a href="qtwebkit-bridge.html">support for hybrid development</a>.</li>
<li>General performance improvements, including the use of &quot;alien widgets&quot; on Mac OS X, the <a href="qstatictext.html">QStaticText</a> class for optimized text rendering, a new <a href="qpainter.html#drawPixmapFragments">API for rendering pixmap fragments</a> and an updated version of the <a href="3rdparty.html#javascriptcore">JavaScriptCore</a> engine for the <a href="qtscript.html">QtScript</a> module with improved performance.</li>
</ul>
<p>In Qt 4.6:</p>
<ul>
<li>Support for <a href="symbian-with-qt-introduction.html">the Symbian Platform</a> as a mainstream Qt platform, with integration into the S60 framework.</li>
<li>The <a href="animation-overview.html">animation framework</a> allows animations to be created using both widgets and graphics items.</li>
<li>The <a href="statemachine-api.html">state machine framework</a> provides a robust state chart implementation based on Harel statecharts and SCXML.</li>
<li>Support for <a href="qtouchevent.html">touch input</a> and <a href="gestures-overview.html">gestures</a> enable developers to create intuitive user interfaces for touch-based devices.</li>
<li>A <a href="qwebelement.html">DOM access API</a> for <a href="qtwebkit.html">QtWebKit</a> provides a cleaner and safer way to access elements and structures of Web pages without the use of JavaScript.</li>
<li>A collection of performance improvements, covering <a href="qgraphicsview.html">QGraphicsView</a>, <a href="qpixmapcache.html">QPixmapCache</a>, <a href="qnetworkaccessmanager.html">QNetworkAccessManager</a>, <a href="qcontiguouscache.html">QContiguousCache</a> class, hardware-accelerated rendering support through <a href="openvg.html">OpenVG</a>, and the removal of Win9x support.</li>
<li>A collection of <a href="qgraphicseffect.html">graphics effects</a> make it easy to apply and simple effects to graphics items and combine them to produce more complex effects.</li>
<li>Support for XML schema validation in the <a href="qtxmlpatterns.html">QtXmlPatterns</a> module covering large parts of version 1.0 of the specification.</li>
<li>Qt3D enablers, including math primitives for <a href="qmatrix4x4.html">matrix multiplication</a>, <a href="qvector3d.html">vectors</a>, <a href="qquaternion.html">quaternions</a> (client-side), and an API for <a href="qglshader.html">vertex and fragment shaders</a>, GLSL/ES.</li>
<li><a href="qtmultimedia.html">Multimedia services</a> providing low-level access to the system's audio system.</li>
</ul>
<p>In Qt 4.5:</p>
<ul>
<li>The WebKit browser engine included with Qt has been upgraded to the latest upstream (trunk) version of WebKit, bringing the latest features and improvements to Qt applications.</li>
<li>Qt for Mac OS X has been substantially rewritten to use Apple's Cocoa API, enabling Qt applications to be deployed on 64-bit Macintosh hardware.</li>
<li>The <a href="qtxmlpatterns.html">QtXmlPatterns</a> module has been extended to cover XSLT, a transformation language for XML documents.</li>
<li>Qt Script introduced its debugger, providing error reporting for scripts, and to let users track down bugs in their own scripts.</li>
<li>Qt 4.5 includes support for writing rich text documents as OpenDocument files via the newly-introduced <a href="qtextdocumentwriter.html">QTextDocumentWriter</a> class.</li>
<li>Qt Linguist can load and edit multiple translation files simultaneously.</li>
<li>Support for ARGB top-level widgets (i.e&#x2e;, translucent windows).</li>
</ul>
<p>In Qt 4.4:</p>
<ul>
<li><a href="qtwebkit.html">Qt WebKit integration</a>, making it possible for developers to use a fully-featured Web browser to display documents and access online services.</li>
<li>A multimedia API provided by the <a href="phonon-overview.html#phonon-overview">Phonon Multimedia Framework</a>.</li>
<li><a href="qtxmlpatterns.html">XQuery and XPath</a> support, providing facilities for XML processing beyond that supported by the <a href="qtxml.html">QtXml</a> module.</li>
<li>Support for embedded widgets in <a href="graphicsview.html#graphics-view">Graphics View</a> scenes.</li>
<li>The <a href="threads.html">QtConcurrent framework</a> for concurrent programming using Qt paradigms and threading features.</li>
<li>An <a href="qthelp.html">improved help system</a> that can be used in conjunction with Qt Assistant or as an independent help resource manager.</li>
<li>Printing system improvements, including the <a href="qprinterinfo.html">QPrinterInfo</a>, <a href="qprintpreviewwidget.html">QPrintPreviewWidget</a> and <a href="qprintpreviewdialog.html">QPrintPreviewDialog</a> classes.</li>
<li>Support for <a href="wince-with-qt-introduction.html">Qt for Windows CE</a> as a mainstream Qt platform.</li>
<li>Improvements in performance of Qt for Embedded Linux and extended support for display hardware.</li>
</ul>
<p>In Qt 4.3:</p>
<ul>
<li>Support for different <a href="qt4-mainwindow.html">main window paradigms and styles</a>, such as those found in Visual Studio or KDevelop.</li>
<li>The <a href="qtscript.html">QtScript</a> module, providing support for application scripting with ECMAScript.</li>
<li>Improved graphics features, including an experimental Direct3D paint engine and improved provision for hardware accelerated rendering with OpenGL, and support for OpenGL ES in Qt for Embedded Linux.</li>
<li><a href="qsvggenerator.html">Scalable Vector Graphics (SVG) export</a>, allowing SVG drawings to be created using the standard <a href="qpainter.html">QPainter</a> API.</li>
<li>Support for arbitrary matrix transformations and set operations on painter paths.</li>
<li>Native look and feel on Windows Vista; improved look and feel on Mac OS X.</li>
<li>An improved <a href="qmdiarea.html">Multiple Document Interface (MDI)</a> implementation.</li>
<li>Continuous improvements to <i>Qt Designer</i>, including support for <a href="designer-widget-mode.html#the-property-editor">dynamic properties</a>.</li>
<li>Support for Secure Socket Layer (SSL) communications via the <a href="qsslsocket.html">QSslSocket</a> class.</li>
<li>Support for XML Localization Interchange File Format (XLIFF) files in <i>Qt Linguist</i>.</li>
<li>A new font subsystem for Qt for Embedded Linux.</li>
</ul>
<p>In Qt 4.2:</p>
<ul>
<li>The <a href="graphicsview.html#graphics-view">Graphics View</a> framework for producing interactive graphics.</li>
<li><a href="desktop-integration.html">Desktop integration</a> facilities for applications.</li>
<li><a href="stylesheet.html">Qt Style Sheets</a> enable easy, yet powerful customization of user interfaces.</li>
<li>Support for the <a href="intro-to-dbus.html">D-Bus</a> Inter-Process Communication (IPC) and Remote Procedure Calling (RPC) mechanism.</li>
<li>An <a href="demos-undo.html">Undo framework</a> based on the <a href="guibooks.html#design-patterns">Command pattern</a>.</li>
<li>Support for model-based <a href="qcompleter.html">text completion</a> in standard and custom widgets.</li>
<li>New widgets and GUI features, such as <a href="qcalendarwidget.html">QCalendarWidget</a> and <a href="qglframebufferobject.html">QGLFramebufferObject</a>.</li>
<li>Classes to provide higher level application infrastructure, such as <a href="qfilesystemwatcher.html">QFileSystemWatcher</a> and <a href="qdatawidgetmapper.html">QDataWidgetMapper</a>.</li>
</ul>
<p>In Qt 4.1:</p>
<ul>
<li>Integrated support for rendering <a href="qt4-arthur.html#svg-rendering-support">Scalable Vector Graphics</a> (SVG) drawings and animations.</li>
<li>Support for <a href="qwidget.html#transparency-and-double-buffering">child widget transparency</a> on all platforms.</li>
<li>A Portable Document Format (PDF) backend for Qt's printing system.</li>
<li>A <a href="qtestlib-manual.html">unit testing framework</a> for Qt applications and libraries.</li>
<li>Modules for <a href="qtdesigner.html">extending <i>Qt Designer</i></a> and <a href="qtuitools.html">dynamic user interface building</a>.</li>
<li>New <a href="model-view-programming.html#proxy-models">proxy models</a> to enable view-specific sorting and filtering of data displayed using item views.</li>
<li>Support for <a href="install-mac.html">universal binaries</a> on Mac OS X.</li>
<li>Additional features for developers using <a href="qtopengl.html">OpenGL</a>, such as support for pixel and sample buffers.</li>
<li>A flexible <a href="qsyntaxhighlighter.html">syntax highlighting class</a> based on the <a href="qt4-scribe.html#scribe">Scribe</a> rich text framework.</li>
<li>Support for <a href="qnetworkproxy.html">network proxy</a> servers using the SOCKS5 protocol.</li>
<li>Support for OLE verbs and MIME data handling in <a href="activeqt.html#activeqt">ActiveQt</a>.</li>
</ul>
<p>For more information about improvements in each Qt release, see the <a href="http://code.qt.io/cgit/qt/qt.git/tree/dist">detailed lists of changes</a>.</p>
<a name="significant-improvements"></a>
<h2>Significant Improvements</h2>
<p>The following modules have been significantly improved for Qt 4:</p>
<ul>
<li>A fully cross-platform <a href="accessibility.html">accessibility</a> module, with support for the emerging SP-API Unix standard in addition to Microsoft and Mac Accessibility.</li>
<li>The <a href="qt4-sql.html">SQL module</a>, which is now based on the Interview model/view framework.</li>
<li>The <a href="qt4-network.html">network module</a>, with better support for UDP and synchronous sockets.</li>
<li>The <a href="qt4-styles.html">style API</a>, which is now decoupled from the widgets, meaning that you can draw any user interface element on any device (widget, pixmap, etc.)&#x2e;</li>
<li>Enhanced <a href="qt4-threads.html">thread support</a>, with signal-slot connections across threads and per-thread event loops.</li>
<li>A new <a href="resources.html#resource-system">resource system</a> for embedding images and other resource files into the application executable.</li>
</ul>
<a name="build-system"></a>
<h2>Build System</h2>
<p>Unlike previous Qt releases, Qt 4 is a collection of smaller libraries. A complete list of libraries in the current release of Qt can be found on the <a href="modules.html">All Modules</a> page. The following table describes the initial set of libraries released with Qt 4.</p>
<table class="generic">
<thead><tr class="qt-style"><th >Library</th><th >Description</th></tr></thead>
<tr valign="top" class="odd"><td ><a href="qtcore.html">QtCore</a></td><td >Core non-GUI functionality</td></tr>
<tr valign="top" class="even"><td ><a href="qtgui.html">QtGui</a></td><td >Core GUI functionality</td></tr>
<tr valign="top" class="odd"><td ><a href="qtnetwork.html">QtNetwork</a></td><td >Network module</td></tr>
<tr valign="top" class="even"><td ><a href="qtopengl.html">QtOpenGL</a></td><td >OpenGL module</td></tr>
<tr valign="top" class="odd"><td ><a href="qtsql.html">QtSql</a></td><td >SQL module</td></tr>
<tr valign="top" class="even"><td ><a href="qtsvg.html">QtSvg</a></td><td >SVG rendering classes</td></tr>
<tr valign="top" class="odd"><td ><a href="qtxml.html">QtXml</a></td><td >XML module</td></tr>
<tr valign="top" class="even"><td ><a href="qt3support.html">Qt3Support</a></td><td >Qt 3 support classes</td></tr>
<tr valign="top" class="odd"><td ><a href="qaxcontainer.html">QAxContainer</a></td><td ><a href="activeqt.html#activeqt">ActiveQt</a> client extension</td></tr>
<tr valign="top" class="even"><td ><a href="qaxserver.html">QAxServer</a></td><td ><a href="activeqt.html#activeqt">ActiveQt</a> server extension</td></tr>
<tr valign="top" class="odd"><td ><a href="qthelp.html">QtHelp</a></td><td >Classes for integrating online documentation</td></tr>
<tr valign="top" class="even"><td ><a href="qtdesigner.html">QtDesigner</a></td><td >Classes for extending and embedding Qt Designer</td></tr>
<tr valign="top" class="odd"><td ><a href="qtuitools.html">QtUiTools</a></td><td >Classes for dynamic GUI generation</td></tr>
<tr valign="top" class="even"><td ><a href="qttest.html">QtTest</a></td><td >Tool classes for unit testing</td></tr>
</table>
<p><a href="qtcore.html">QtCore</a> contains tool classes like <a href="qstring.html">QString</a>, <a href="qlist.html">QList</a>, and <a href="qfile.html">QFile</a>, as well as kernel classes like <a href="qobject.html">QObject</a> and <a href="qtimer.html">QTimer</a>. The <a href="qapplication.html">QApplication</a> class has been refactored so that it can be used in non-GUI applications. It is split into <a href="qcoreapplication.html">QCoreApplication</a> (in <a href="qtcore.html">QtCore</a>) and <a href="qapplication.html">QApplication</a> (in <a href="qtgui.html">QtGui</a>).</p>
<p>This split makes it possible to develop server applications using Qt without linking in any unnecessary GUI-related code and without requiring GUI-related system libraries to be present on the target machine (e.g&#x2e; Xlib on X11, Carbon on Mac OS X).</p>
<p>If you use qmake to generate your makefiles, qmake will by default link your application against <a href="qtcore.html">QtCore</a> and <a href="qtgui.html">QtGui</a>. To remove the dependency upon <a href="qtgui.html">QtGui</a>, add the line</p>
<pre class="cpp"> QT -= gui</pre>
<p>to your .pro file. To enable the other libraries, add the line</p>
<pre class="cpp"> QT += network opengl sql qt3support</pre>
<p>Another change to the build system is that moc now understands preprocessor directives. qmake automatically passes the defines set for your project (using &quot;DEFINES +=&quot;) on to moc, which has its own built-in C++ preprocessor.</p>
<p>To compile code that uses UI files, you will also need this line in the .pro file:</p>
<pre class="cpp"> CONFIG += uic3</pre>
<a name="include-syntax"></a>
<h2>Include Syntax</h2>
<p>The syntax for including Qt class definitions has become</p>
<pre class="cpp"> <span class="preprocessor">#include &lt;QClassName&gt;</span></pre>
<p>For example:</p>
<pre class="cpp"> <span class="preprocessor">#include &lt;QString&gt;</span>
 <span class="preprocessor">#include &lt;QApplication&gt;</span>
 <span class="preprocessor">#include &lt;QSqlTableModel&gt;</span></pre>
<p>This is guaranteed to work for any public Qt class. The old syntax,</p>
<pre class="cpp"> <span class="preprocessor">#include &lt;qclassname.h&gt;</span></pre>
<p>still works, but we encourage you to switch to the new syntax.</p>
<p>If you attempt to include a header file from a library that isn't linked against the application, this will result in a compile-time warning (e.g&#x2e;, &quot;<a href="qsqlquery.html">QSqlQuery</a>: No such file or directory&quot;). You can remedy to this problem either by removing the offending include or by specifying the missing library in the QT entry of your <tt>.pro</tt> file (see <a href="#build-system">Build System</a> above).</p>
<p>To include the definitions for all the classes in a library, simply specify the name of that library. For example:</p>
<pre class="cpp"> <span class="preprocessor">#include &lt;QtCore&gt;</span></pre>
<a name="namespaces"></a>
<h2>Namespaces</h2>
<p>Qt 2 introduced a class called Qt for global-like constants (e.g&#x2e;, <tt>Qt::yellow</tt>). The C++ namespace construct was not used because not all compilers understood it when it was released.</p>
<p>With Qt 4, the Qt class has become the Qt namespace. If you want to access a constant that is part of the Qt namespace, prefix it with <tt>Qt::</tt> (e.g&#x2e;, <tt>Qt::yellow</tt>), or add the directive</p>
<pre class="cpp"> <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="type"><a href="qt.html">Qt</a></span>;</pre>
<p>at the top of your source files, after your <tt>#include</tt> directives. If you use the <tt>using namespace</tt> syntax you don't need the prefix (e.g&#x2e;, <tt>yellow</tt> is sufficient).</p>
<p>When porting Qt 3 applications, you may run into some source compatibility problems with some of these symbols. For example, in Qt 3, it was legal to write <tt>QWidget::yellow</tt> instead of <tt>Qt::yellow</tt>, because <a href="qwidget.html">QWidget</a> inherited from Qt. This won't work in Qt 4; you must write <tt>Qt::yellow</tt> or add the &quot;using namespace&quot; directive and drop the <tt>Qt::</tt> prefix.</p>
<p>The <a href="qt3to4.html">qt3to4</a> porting tool automates this conversion.</p>
<a name="qobject-qwidget-constructors"></a>
<h2>QObject/QWidget Constructors</h2>
<p>In Qt 4 we have tried to simplify the constructors of <a href="qobject.html">QObject</a>/<a href="qwidget.html">QWidget</a> subclasses. This makes subclassing easier, at the same time as it helps make the Qt library more efficient.</p>
<p>Constructors no longer take a &quot;const char *name&quot; parameter. If you want to specify a name for a <a href="qobject.html">QObject</a>, you must call <a href="qobject.html#objectName-prop">QObject::setObjectName</a>() after construction. The object name is now a <a href="qstring.html">QString</a>. The reasons for this change are:</p>
<ul>
<li>Code that used it looked confusing, for example:<pre class="cpp"> <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>label1 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(<span class="string">&quot;Hello&quot;</span><span class="operator">,</span> <span class="keyword">this</span>);
 <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>label2 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(<span class="keyword">this</span><span class="operator">,</span> <span class="string">&quot;Hello&quot;</span>);</pre>
<p><tt>label1</tt> is a <a href="qlabel.html">QLabel</a> that displays the text &quot;Hello&quot;; <tt>label2</tt> is a <a href="qlabel.html">QLabel</a> with no text, with the object name &quot;Hello&quot;.</p>
</li>
<li>From surveys we did, most users didn't use the name, although they blindly followed Qt's convention and provided a &quot;const char *name&quot; in their subclasses's constructors. For example:<pre class="cpp"> MyWidget<span class="operator">::</span>MyWidget(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent<span class="operator">,</span> <span class="keyword">const</span> <span class="type">char</span> <span class="operator">*</span>name)
     : <span class="type"><a href="qwidget.html">QWidget</a></span>(parent<span class="operator">,</span> name)
 {
     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 }</pre>
</li>
<li>The name parameter was in Qt since version 1, and it always was documented as: &quot;It is not very useful in the current version of Qt, but it will become increasingly important in the future.&quot; Ten years later, it still hasn't fulfilled its promise.</li>
</ul>
<p><a href="qwidget.html">QWidget</a>'s <tt>WFlags</tt> data type has been split in two: <a href="qt.html#WindowType-enum">Qt::WindowFlags</a> specifies low-level window flags (the type of window and the frame style), whereas <a href="qt.html#WidgetAttribute-enum">Qt::WidgetAttribute</a> specifies various higher-level attributes about the widget (e.g&#x2e;, WA_StaticContents). Widget attributes can be set at any time using <a href="qwidget.html#setAttribute">QWidget::setAttribute</a>(); low-level window flags can be passed to the <a href="qwidget.html">QWidget</a> constructor or set later using <a href="qwidget.html#setParent">QWidget::setParent</a>(). As a consequence, the constructors of most <a href="qwidget.html">QWidget</a> subclasses don't need to provide a <tt>WFlags</tt> parameter.</p>
<p>The <i>parent</i> parameter of all <a href="qobject.html">QObject</a> classes in Qt defaults to a 0 pointer, as it used to do in Qt 1. This enables a style of programming where widgets are created without parents and then inserted in a layout, at which point the layout automatically reparents them.</p>
<a name="dynamic-casts"></a>
<h2>Dynamic Casts</h2>
<p>Qt 4 provides a qobject_cast&lt;&gt;() function that performs a dynamic cast based on the meta-information generated by moc for <a href="qobject.html">QObject</a> subclasses. Unlike the standard C++ <a href="#dynamic-casts">dynamic_cast</a>&lt;&gt;() construct, qobject_cast&lt;&gt;() works even when RTTI is disabled, and it works correctly across DLL boundaries.</p>
<p>Here's the Qt 3 idiom to cast a type to a subtype:</p>
<pre class="cpp"> <span class="comment">// DEPRECATED</span>
 <span class="keyword">if</span> (obj<span class="operator">-</span><span class="operator">&gt;</span>inherits(<span class="string">&quot;QPushButton&quot;</span>)) {
     <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>pushButton <span class="operator">=</span> (<span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>)obj;
     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 }</pre>
<p>The Qt 4 idiom is both cleaner and safer, because typos will always result in compiler errors:</p>
<pre class="cpp"> <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>pushButton <span class="operator">=</span> qobject_cast<span class="operator">&lt;</span><span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span><span class="operator">&gt;</span>(obj);
 <span class="keyword">if</span> (pushButton) {
     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 }</pre>
<a name="qpointer-t"></a>
<h2>QPointer&lt;T&gt;</h2>
<p>The <a href="qpointer.html">QPointer</a>&lt;T&gt; class provides a pointer to type T (where T inherits from <a href="qobject.html">QObject</a>) that is automatically set to 0 when the referenced object is destroyed. Guarded pointers are useful whenever you want to store a pointer to an object you do not own.</p>
<p>Example:</p>
<pre class="cpp"> <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>label <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
 <span class="type"><a href="qpointer.html">QPointer</a></span><span class="operator">&lt;</span><span class="type"><a href="qlabel.html">QLabel</a></span><span class="operator">&gt;</span> safeLabel <span class="operator">=</span> label;
 safeLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(<span class="string">&quot;Hello world!&quot;</span>);
 <span class="keyword">delete</span> label;
 <span class="comment">// safeLabel is now 0, whereas label is a dangling pointer</span></pre>
<p><a href="qpointer.html">QPointer</a>&lt;T&gt; is more or less the same as the old QGuardedPtr&lt;T&gt; class, except that it is now implemented in a much more lightweight manner than before. The cost of one <a href="qpointer.html">QPointer</a>&lt;T&gt; object is now approximately the same as that of a signal--slot connection.</p>
<a name="paint-events"></a>
<h2>Paint Events</h2>
<p>Qt 4 supports double buffering transparently on all platforms. This feature can be turned off on a per-widget basis by calling QWidget::setAttribute(<a href="qt.html#WidgetAttribute-enum">Qt::WA_PaintOnScreen</a>).</p>
<p>A consequence of this is that all painting must now be done from the paintEvent() function. This is also required by the HIView API on Mac OS X. In practice, this is seldom a problem, since you can call update() from anywhere in your code to create a paint event, with the region to update as the argument.</p>
<p>To help porting, <a href="qwidget.html">QWidget</a> supports a <a href="qt.html#WidgetAttribute-enum">Qt::WA_PaintOutsidePaintEvent</a> attribute that can be set to make it possible to paint outside <a href="qwidget.html#paintEvent">paintEvent()</a> on Windows and X11.</p>
<a name="qt-3-support-layer"></a>
<h2>Qt 3 Support Layer</h2>
<p>Qt 4 provides an extension library that applications based on Qt 3, called <a href="qt3support.html">Qt3Support</a>, that Qt applications can link against. This allows for more compatibility than ever before, without bloating Qt.</p>
<ul>
<li>Classes that have been replaced by a different class with the same name, such as <a href="qlistview.html">QListView</a>, and classes that no longer exist in Qt 4 are available with a <tt>3</tt> in their name (e.g&#x2e;, <a href="q3listview.html" class="compat">Q3ListView</a>, <a href="q3accel.html" class="compat">Q3Accel</a>).</li>
<li>Other classes provide compatibility functions. Most of these are implemented inline, so that they don't bloat the Qt libraries.</li>
</ul>
<p>To enable the Qt 3 support classes and functions, add the line</p>
<pre class="cpp"> QT += qt3support</pre>
<p>to your <tt>.pro</tt> file.</p>
<p>On Visual C++ 7 and GCC 3.2+, using compatibility functions often results in a compiler warning (e.g&#x2e;, &quot;'find' is deprecated&quot;). If you want to turn off that warning, add the line</p>
<pre class="cpp"> DEFINES += QT3_SUPPORT</pre>
<p>to your <tt>.pro</tt> file.</p>
<p>If you want to use compatibility functions but don't want to link against the <a href="qt3support.html">Qt3Support</a> library, add the line</p>
<pre class="cpp"> DEFINES += QT3_SUPPORT_WARNINGS</pre>
<p>or</p>
<pre class="cpp"> DEFINES += QT3_SUPPORT</pre>
<p>to your <tt>.pro</tt> file, depending on whether you want compatibility function calls to generate compiler warnings or not.</p>
</div>
<!-- @@@qt4-intro.html -->
<p class="naviNextPrevious footerNavi">
<a class="nextPage" href="qt4-tulip.html">The Tulip Container Classes</a>
</p>
      </div>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2015 The Qt Company Ltd.
      Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      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.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      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. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
  </div>

  <script src="scripts/functions.js" type="text/javascript"></script>
</body>
</html>