Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 50facae208d4a6f280e44a513b104320 > files > 1924

qt-mobility-doc-1.2.0-13.mga5.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" />
<!-- sysinfo.qdoc -->
  <title>Qt Mobility 1.2: System Information Example</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>QtMobility Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li><a href="http://qt.nokia.com/doc/4.7/all-examples.html">Examples</a></li>
<li>System Information Example</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<h1 class="title">System Information Example</h1>
<span class="subtitle"></span>
<!-- $$$sysinfo-description -->
<div class="descr"> <a name="details"></a>
<p>Files:</p>
<ul>
<li><a href="sysinfo-dialog-cpp.html">sysinfo/dialog.cpp</a></li>
<li><a href="sysinfo-dialog-h.html">sysinfo/dialog.h</a></li>
<li><a href="sysinfo-dialog-ui.html">sysinfo/dialog.ui</a></li>
<li><a href="sysinfo-dialog-landscape-ui.html">sysinfo/dialog_landscape.ui</a></li>
<li><a href="sysinfo-dialog-s60-ui.html">sysinfo/dialog_s60.ui</a></li>
<li><a href="sysinfo-dialog-small-landscape-ui.html">sysinfo/dialog_small_landscape.ui</a></li>
<li><a href="sysinfo-main-cpp.html">sysinfo/main.cpp</a></li>
<li><a href="sysinfo-examples-qrc.html">sysinfo/examples.qrc</a></li>
<li><a href="sysinfo-sysinfo-pro.html">sysinfo/sysinfo.pro</a></li>
</ul>
<p class="centerAlign"><img src="images/sysinfo.png" alt="" /></p><p>The System Information example uses a tabbed dialog, with each tab representing a particular type of data: versions, network and so on.</p>
<p>To access the information, the example creates objects belonging to the System Information classes</p>
<table class="annotated">
<tr class="odd topAlign"><td class="tblName"><p><a href="qsystemdeviceinfo-profiledetails.html">QSystemDeviceInfo::ProfileDetails</a></p></td><td class="tblDescr"><p>Access to details of the currently active phone profile</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qsystemalignedtimer.html">QSystemAlignedTimer</a></p></td><td class="tblDescr"><p>Service for applications to synchronize their activity</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qsystembatteryinfo.html">QSystemBatteryInfo</a></p></td><td class="tblDescr"><p>Access to battery and power information from the system</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qsystemdeviceinfo.html">QSystemDeviceInfo</a></p></td><td class="tblDescr"><p>Access to device information from the system</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qsystemdisplayinfo.html">QSystemDisplayInfo</a></p></td><td class="tblDescr"><p>Access to display information from the system</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qsysteminfo.html">QSystemInfo</a></p></td><td class="tblDescr"><p>Access to various general information from the system</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qsystemnetworkinfo.html">QSystemNetworkInfo</a></p></td><td class="tblDescr"><p>Access to various networking status and signals</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qsystemscreensaver.html">QSystemScreenSaver</a></p></td><td class="tblDescr"><p>Access to screen saver and blanking</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qsystemstorageinfo.html">QSystemStorageInfo</a></p></td><td class="tblDescr"><p>Access to disk storage information from the system</p></td></tr>
</table>
<p>Here are some examples that show how the example application reads the device information.</p>
<p>The current language</p>
<pre class="cpp">     systemInfo <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qsysteminfo.html">QSystemInfo</a></span>(<span class="keyword">this</span>);
     curLanguageLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setText( systemInfo<span class="operator">-</span><span class="operator">&gt;</span>currentLanguage());</pre>
<p>Device information, starting with the battery level</p>
<pre class="cpp"> bi <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qsystembatteryinfo.html">QSystemBatteryInfo</a></span>(<span class="keyword">this</span>);
     ...
 chargerTypeChanged(bi<span class="operator">-</span><span class="operator">&gt;</span>chargerType());

 currentBatStat <span class="operator">=</span> bi<span class="operator">-</span><span class="operator">&gt;</span>batteryStatus();</pre>
<p>The battery status is an enum, <a href="qsystembatteryinfo.html#BatteryStatus-enum">QSystemBatteryInfo::BatteryStatus</a>, that indicates various battery levels and their significance, e.g&#x2e;, <a href="qsystembatteryinfo.html#BatteryStatus-enum">QSystemBatteryInfo::BatteryVeryLow</a>.</p>
<p>The manufacturer id and the product name</p>
<pre class="cpp">     manufacturerLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(di<span class="operator">-</span><span class="operator">&gt;</span>manufacturer());
     ...
     productLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(di<span class="operator">-</span><span class="operator">&gt;</span>productName());</pre>
<p>Other information is stored as bitwise flags. The following code shows the input methods being determined using flags.</p>
<pre class="cpp">     <span class="type"><a href="qsystemdeviceinfo.html">QSystemDeviceInfo</a></span><span class="operator">::</span>InputMethodFlags methods <span class="operator">=</span> di<span class="operator">-</span><span class="operator">&gt;</span>inputMethodType();
     <span class="type"><a href="http://qt.nokia.com/doc/4.7/qstringlist.html">QStringList</a></span> inputs;
     <span class="keyword">if</span> ((methods <span class="operator">&amp;</span> <span class="type"><a href="qsystemdeviceinfo.html">QSystemDeviceInfo</a></span><span class="operator">::</span>Keys)<span class="operator">=</span><span class="type"><a href="qsystemdeviceinfo.html">QSystemDeviceInfo</a></span><span class="operator">::</span>Keypad){
         inputs <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;Keys&quot;</span>;
     }
     <span class="keyword">if</span> ((methods <span class="operator">&amp;</span> <span class="type"><a href="qsystemdeviceinfo.html">QSystemDeviceInfo</a></span><span class="operator">::</span>Keypad)<span class="operator">=</span><span class="type"><a href="qsystemdeviceinfo.html">QSystemDeviceInfo</a></span><span class="operator">::</span>Keypad) {
         inputs <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;Keypad&quot;</span>;
     }</pre>
<p>Various capabilities of the device can be found by testing for features. In the example a Feature combo box, on the General tab, has a hard coded list of features. When a listed feature is selected the getFeature() function is called with the index which is handled by applying a test to the corresponding feature.</p>
<pre class="cpp">     <span class="type"><a href="qsysteminfo.html">QSystemInfo</a></span><span class="operator">::</span>Feature feature;
     <span class="keyword">switch</span>(index) {
     ...
     <span class="keyword">case</span> <span class="number">1</span>:
         feature <span class="operator">=</span> <span class="type"><a href="qsysteminfo.html">QSystemInfo</a></span><span class="operator">::</span>BluetoothFeature;
     ...
     <span class="type"><a href="qsysteminfo.html">QSystemInfo</a></span> si;
     featuresLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setText((si<span class="operator">.</span>hasFeatureSupported(feature) <span class="operator">?</span> <span class="string">&quot;true&quot;</span>:<span class="string">&quot;false&quot;</span> ));</pre>
</div>
<!-- @@@sysinfo -->
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
  <p>
     <acronym title="Copyright">&copy;</acronym> 2008-2011 Nokia Corporation and/or its
     subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
     in Finland and/or other countries worldwide.</p>
  <p>
     All other trademarks are property of their respective owners. <a title="Privacy Policy"
     href="http://qt.nokia.com/about/privacy-policy">Privacy Policy</a></p>
  <br />
  <p>
    Licensees holding valid Qt Commercial licenses may use this document in accordance with the    Qt Commercial License Agreement provided with the Software or, alternatively, in accordance    with the terms contained in a written agreement between you and Nokia.</p>
  <p>
    Alternatively, this document may be used 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>
</div>
</body>
</html>