Sophie

Sophie

distrib > Mageia > 6 > x86_64 > media > core-updates > by-pkgid > dbf69eaa13c86c67c80d31d9cbb7847c > files > 3431

qtbase5-doc-5.9.4-1.2.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" />
<!-- qmacnativewidget_mac.mm -->
  <title>QMacNativeWidget Class | Qt Widgets 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="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-module.html">C++ Classes</a></td><td >QMacNativeWidget</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="#reimplemented-public-functions">Reimplemented Public Functions</a></li>
<li class="level1"><a href="#reimplemented-protected-functions">Reimplemented Protected 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">QMacNativeWidget Class</h1>
<!-- $$$QMacNativeWidget-brief -->
<p>The <a href="qmacnativewidget.html">QMacNativeWidget</a> class provides a widget for macOS that provides a way to put Qt widgets into Cocoa hierarchies. <a href="#details">More...</a></p>
<!-- @@@QMacNativeWidget -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QMacNativeWidget&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += widgets</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 4.5</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qwidget.html">QWidget</a></td></tr></table></div><ul>
<li><a href="qmacnativewidget-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"> </td><td class="memItemRight bottomAlign"><b><a href="qmacnativewidget.html#QMacNativeWidget">QMacNativeWidget</a></b>(NSView *<i>parentView</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmacnativewidget.html#dtor.QMacNativeWidget">~QMacNativeWidget</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> NSView *</td><td class="memItemRight bottomAlign"><b><a href="qmacnativewidget.html#nativeView">nativeView</a></b>() const</td></tr>
</table></div>
<a name="reimplemented-public-functions"></a>
<h2 id="reimplemented-public-functions">Reimplemented Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual QSize </td><td class="memItemRight bottomAlign"><b><a href="qmacnativewidget.html#sizeHint">sizeHint</a></b>() const override</td></tr>
</table></div>
<ul>
<li class="fn">214 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
<li class="fn">32 public functions inherited from <a href="../qtcore/qobject.html#public-functions">QObject</a></li>
<li class="fn">14 public functions inherited from <a href="../qtgui/qpaintdevice.html#public-functions">QPaintDevice</a></li>
</ul>
<a name="reimplemented-protected-functions"></a>
<h2 id="reimplemented-protected-functions">Reimplemented Protected Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qmacnativewidget.html#event">event</a></b>(QEvent *<i>ev</i>) override</td></tr>
</table></div>
<ul>
<li class="fn">35 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li>
<li class="fn">1 protected function inherited from <a href="../qtgui/qpaintdevice.html#protected-functions">QPaintDevice</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">59 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
<li class="fn">1 property inherited from <a href="../qtcore/qobject.html#properties">QObject</a></li>
<li class="fn">19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
<li class="fn">1 public slot inherited from <a href="../qtcore/qobject.html#public-slots">QObject</a></li>
<li class="fn">3 signals inherited from <a href="qwidget.html#signals">QWidget</a></li>
<li class="fn">2 signals inherited from <a href="../qtcore/qobject.html#signals">QObject</a></li>
<li class="fn">1 public variable inherited from <a href="../qtcore/qobject.html#public-variables">QObject</a></li>
<li class="fn">5 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
<li class="fn">10 static public members inherited from <a href="../qtcore/qobject.html#static-public-members">QObject</a></li>
<li class="fn">35 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li>
<li class="fn">1 protected function inherited from <a href="../qtgui/qpaintdevice.html#protected-functions">QPaintDevice</a></li>
<li class="fn">1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li>
<li class="fn">2 protected variables inherited from <a href="../qtcore/qobject.html#protected-variables">QObject</a></li>
<li class="fn">1 protected type inherited from <a href="../qtgui/qpaintdevice.html#protected-variables">QPaintDevice</a></li>
</ul>
<a name="details"></a>
<!-- $$$QMacNativeWidget-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qmacnativewidget.html">QMacNativeWidget</a> class provides a widget for macOS that provides a way to put Qt widgets into Cocoa hierarchies.</p>
<p>On macOS, there is a difference between a window and view; normally expressed as widgets in Qt. Qt makes assumptions about its parent-child hierarchy that make it complex to put an arbitrary Qt widget into a hierarchy of &quot;normal&quot; views from Apple frameworks. <a href="qmacnativewidget.html">QMacNativeWidget</a> bridges the gap between views and windows and makes it possible to put a hierarchy of Qt widgets into a non-Qt window or view.</p>
<p><a href="qmacnativewidget.html">QMacNativeWidget</a> pretends it is a window (i.e&#x2e; <a href="qwidget.html#isWindow">isWindow</a>() will return true), but it cannot be shown on its own. It needs to be put into a window when it is created or later through a native call.</p>
<p>Here is an example showing how to put a <a href="qpushbutton.html">QPushButton</a> into a NSWindow:</p>
<pre class="cpp">

      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
      NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(200, app.desktop()-&gt;height() - 200, 239, 200)
                          styleMask:NSTitledWindowMask | NSClosableWindowMask
                                    | NSMiniaturizableWindowMask | NSResizableWindowMask
                          backing:NSBackingStoreBuffered defer:NO];

      QMacNativeWidget *nativeWidget = new QMacNativeWidget();
      nativeWidget-&gt;move(0, 0);
      nativeWidget-&gt;setPalette(QPalette(Qt::red));
      nativeWidget-&gt;setAutoFillBackground(true);
      QVBoxLayout *layout = new QVBoxLayout();
      QPushButton *pushButton = new QPushButton(&quot;An Embedded Qt Button!&quot;, nativeWidget);
      pushButton-&gt;setAttribute(Qt::WA_LayoutUsesWidgetRect); // Don't use the layout rect calculated from QMacStyle.
      layout-&gt;addWidget(pushButton);
      nativeWidget-&gt;setLayout(layout);

      // Adjust Cocoa layouts
      NSView *nativeWidgetView = reinterpret_cast&lt;NSView *&gt;(nativeWidget-&gt;winId());
      NSView *contentView = [window contentView];
      [contentView setAutoresizesSubviews:YES];
      [nativeWidgetView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
      [nativeWidgetView setAutoresizesSubviews:YES];
      NSView *pushButtonView = reinterpret_cast&lt;NSView *&gt;(pushButton-&gt;winId());
      [pushButtonView setAutoresizingMask:NSViewWidthSizable];

      // Add the nativeWidget to the window.
      [contentView addSubview:nativeWidgetView positioned:NSWindowAbove relativeTo:nil];
      nativeWidget-&gt;show();
      pushButton-&gt;show();

      // Show the window.
      [window makeKeyAndOrderFront:window];
      [pool release];

</pre>
<p>Note that <a href="qmacnativewidget.html">QMacNativeWidget</a> requires knowledge of Cocoa. All it does is get the Qt hierarchy into a window not owned by Qt. It is then up to the programmer to ensure it is placed correctly in the window and responds correctly to events.</p>
</div>
<!-- @@@QMacNativeWidget -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QMacNativeWidget[overload1]$$$QMacNativeWidgetNSView* -->
<h3 class="fn" id="QMacNativeWidget"><a name="QMacNativeWidget"></a>QMacNativeWidget::<span class="name">QMacNativeWidget</span>(<span class="type">NSView</span> *<i>parentView</i> = Q_NULLPTR)</h3>
<p>Create a <a href="qmacnativewidget.html">QMacNativeWidget</a> with <i>parentView</i> as its &quot;superview&quot; (i.e&#x2e;, parent). The <i>parentView</i> is a NSView pointer.</p>
<!-- @@@QMacNativeWidget -->
<!-- $$$~QMacNativeWidget[overload1]$$$~QMacNativeWidget -->
<h3 class="fn" id="dtor.QMacNativeWidget"><a name="dtor.QMacNativeWidget"></a>QMacNativeWidget::<span class="name">~QMacNativeWidget</span>()</h3>
<p>Destroy the <a href="qmacnativewidget.html">QMacNativeWidget</a>.</p>
<!-- @@@~QMacNativeWidget -->
<!-- $$$event[overload1]$$$eventQEvent* -->
<h3 class="fn" id="event"><a name="event"></a><code>[override virtual protected] </code><span class="type">bool</span> QMacNativeWidget::<span class="name">event</span>(<span class="type"><a href="../qtcore/qevent.html">QEvent</a></span> *<i>ev</i>)</h3>
<p>Reimplemented from <a href="../qtcore/qobject.html#event">QObject::event</a>().</p>
<!-- @@@event -->
<!-- $$$nativeView[overload1]$$$nativeView -->
<h3 class="fn" id="nativeView"><a name="nativeView"></a><span class="type">NSView</span> *QMacNativeWidget::<span class="name">nativeView</span>() const</h3>
<p>Returns the native view backing the <a href="qmacnativewidget.html">QMacNativeWidget</a>.</p>
<!-- @@@nativeView -->
<!-- $$$sizeHint[overload1]$$$sizeHint -->
<h3 class="fn" id="sizeHint"><a name="sizeHint"></a><code>[override virtual] </code><span class="type"><a href="../qtcore/qsize.html">QSize</a></span> QMacNativeWidget::<span class="name">sizeHint</span>() const</h3>
<p>Reimplemented from <a href="qwidget.html#sizeHint-prop">QWidget::sizeHint</a>().</p>
<!-- @@@sizeHint -->
</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>