Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > d5e62c01ae8d1e579463c6a871dd44bf > files > 5094

qtbase5-doc-5.12.6-2.mga7.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" />
<!-- mousebuttons.qdoc -->
  <title>Mouse Button Tester | Qt Widgets 5.12.6</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.12</td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td >Mouse Button Tester</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtwidgets-index.html">Qt 5.12.6 Reference Documentation</a></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="#the-main-program">The Main Program</a></li>
<li class="level1"><a href="#buttontester-class-definition">ButtonTester Class Definition</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Mouse Button Tester</h1>
<span class="subtitle"></span>
<!-- $$$widgets/mousebuttons-brief -->
<p>The 'Mouse Button Tester' example demonstrates how to reimplement mouse events within a custom class. You can also use this program to verify that Qt is actually receiving mouse events from your mouse.</p>
<!-- @@@widgets/mousebuttons -->
<!-- $$$widgets/mousebuttons-description -->
<div class="descr"> <a name="details"></a>
<p>Many 'gamer' mouse devices are configured with high-numbered &quot;buttons&quot; sending text shortcuts for certain games. With such a mouse, no mouse button events occur: The &quot;mouse&quot; sends keystrokes, and the 'Mouse Button Tester' Window will not see the event. Receiving no event, it will not repaint the Window with new text describing a button event.</p>
<p>And so, in addition to it's use as Qt example code, the program may be useful s a mouse device tester. Note that there is another example mouse buttons example which provides the same function, written in QML.</p>
<p>This program (the Widget-based example) consists of three classes, in addition to the main() parent program:</p>
<ul>
<li><code>A</code> <a href="qpushbutton.html">QPushButton</a>, &quot;Quit&quot;.</li>
<li><code>ButtonTester</code>. This is derived from Qt's TextArea class, for purpose of customizing/re-implementing the mouse and wheel event member functions.</li>
<li><code>A</code> simple <a href="qvboxlayout.html">QVBoxLayout</a> layout.</li>
</ul>
<p>First we will review the main program, with it's layout and &quot;Quit&quot; <a href="qpushbutton.html">QPushButton</a>. Then we will take a look at the <code>ButtonTester</code> class.</p>
<a name="the-main-program"></a>
<h2 id="the-main-program">The Main Program</h2>
<p>Note that the <a href="qpushbutton.html">QPushButton</a>, &quot;Quit&quot;, is defined directly within the main() program, rather than another class. This is a correct way of defining a &quot;Quit&quot; <a href="qpushbutton.html">QPushButton</a>: A &quot;Quit&quot; Button defined inside another class would result in the destructor of that second class being called twice. This &quot;Quit&quot; Button uses the traditional Signal/Slot connection to invoke termination of the QApp, which will properly destroy its child classes before terminating itself.</p>
<p>The remainder of the main() program is concerned with defining the layout, and applying a minimum size to the customized ButtonTester.</p>
<a name="buttontester-class-definition"></a>
<h2 id="buttontester-class-definition">ButtonTester Class Definition</h2>
<p>The <code>ButtonTester</code> class inherits from <a href="qtextedit.html">QTextEdit</a>, and listens for mouse events on all possible <a href="../qtcore/qt.html#MouseButton-enum">Qt::MouseButton</a> values. It also listens for wheel events from the mouse, and indicates the direction of wheel motion (&quot;up&quot;, down&quot;, &quot;left&quot;, or &quot;right&quot;). It prints short debug messages into the Window, and also on the console QDebug() stream, when mouse button and wheel events occur. Our reimplementation of mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), and wheelEvent() &quot;drive&quot; the program; the other functions simply convert the <a href="../qtcore/qt.html#MouseButton-enum">Qt::MouseButton</a> values into text strings.</p>
<p>You should call the ignore() function on any mouse event (or other event) which your widget-based classes do not use and consume. This function assures that Qt will propagate the event through each parent widget, until it is used or propagated to the Window Manager. (Qt attempts to do this automatically, but it is better programming practice to explicitly invoke the function.)</p>
<p class="centerAlign"><img src="images/mousebutton-buttontester.png" alt="" /></p><p>Files:</p>
<ul>
<li><a href="qtwidgets-widgets-mousebuttons-buttontester-cpp.html">widgets/mousebuttons/buttontester.cpp</a></li>
<li><a href="qtwidgets-widgets-mousebuttons-buttontester-h.html">widgets/mousebuttons/buttontester.h</a></li>
<li><a href="qtwidgets-widgets-mousebuttons-main-cpp.html">widgets/mousebuttons/main.cpp</a></li>
<li><a href="qtwidgets-widgets-mousebuttons-mousebuttons-pro.html">widgets/mousebuttons/mousebuttons.pro</a></li>
</ul>
</div>
<!-- @@@widgets/mousebuttons -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 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>