?? phoneapps.html
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/edba/dist/qtopia/main-Sunday/qtopia/doc/phoneapps.doc:1 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="200" align="left" valign="top"><a href="index.html"><img height="27" width="472" src="dochead.png" border="0"></a><br><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" align="center" size=32>Qtopia</font> <a href="index.html">Home</a> - <a href="qtopiaclasses.html">Classes</a> - <a href="qtopiaannotated.html">Annotated</a> - <a href="qtopiafunctions.html">Functions</a> - <a href="qtindex.html">Qt Embedded</a></td><td align="right" valign="top"> <table border="0" cellpadding="0" cellspacing="0" width="137"> <tr> <td><a href="http://www.trolltech.com/company/about/trolls.html"><img height="100" width="100" src="face.png" border="0"></a></td> <td><img height="100" width="100" src="qtlogo.png" align="top" border="0"></td> </tr> </table></td></tr></table><p> <p> <h2> Qtopia - Writing Applications for Phones</h2><a name="1"></a><p> The Qtopia phone edition is tuned for use on a mobile phone, without atouch screen. All Qt and Qtopia widgets have been modified for use witha small set of keys:<p> <ul><li> a context key - usually used to display a context menu, or performa specific task based on the current context.<li> a select key - used to select a widget for editing, an item from a list, etc.<li> a back key - used to cancel the current operation, or go back to theprevious screen.<li> arrow keys<li> keypad - used for numeric and text input (via input methods).</ul><p> Applications written for Qtopia and Qtopia Phone edition usually share 99%of their code, however, it is necessary to make some allowances for phoneusage.<p> The required user interface changes are:<p> <ul><li> The phone should have no menu bar or tool bars.<li> The user interface must be navigatable using only the keys specified above.</ul><p> In addition, phones usually have lower resolution screens, but have highervisibility requirements than PDA's. This often requires changes to theuser interface to allow using larger fonts on less available screen real-estate.<p> Code specific to the Qtopia phone edition can be included or excluded usingthe QTOPIA_PHONE macro.<p> <pre>#ifdef QTOPIA_PHONE // phone specific code#endif</pre> <p> <h3> Modal Editing</h3><a name="1-1"></a><p> In order to navigate using only the keys specified above, widgets have twofocus states:<ul><li> nonmodal editing<li> modal editing</ul><p> Nonmodal editing allows navigation between widgets. When a widget firstgains focus it will be in nonmodal editing state. In this state, thewidget should ignore all key events, except Qt::Key_Select, which can either:<p> <ul><li> edit/activate the widget if sensible, e.g. pressing select on aQCheckBox will check/uncheck the box, otherwise,<li> enter modal editing state so that further editing can be performed. Inthis case, either Qt::Key_Back or Qt::Key_Select may be used to end modal editing.</ul><p> The modal editing state of a widget is set using<pre> QWidget::setModalEditing(bool)</pre> and accessed using<pre> bool QWidget::isModalEditing().</pre> <p> <h3> The Context Bar</h3><a name="1-2"></a><p> Some phones have soft keys which may have different meanings in differentcontexts. On these phones the Qtopia phone edition server displays aContext bar at the bottom of the screen. This bar displays the actionsthat the corresponding button on thephone will perform. You can set the label to be displayed in thecontext bar using the <a href="contextbar.html">ContextBar</a> class.<p> For example, to set the Qt::Key_Context1 label of a widget to the standard Editlabel when it is in modal editing state:<p> <pre> ContextBar::<a href="contextbar.html#setLabel">setLabel</a>(widget, Qt::Key_Context1, ContextBar::Edit, ContextBar::Modal);</pre> <p> It is also possible to set custom labels using:<p> <pre> ContextBar::<a href="contextbar.html#setLabel">setLabel</a>(QWidget *, int key, const QString &pixmap, const QString &text, EditingState state);</pre> <p> In this case the pixmap name and a short text label are specified. Thepixmap must always be provided so that themes with limited space can displaya pixmap rather than longer text. The text is optional, but recommeded. Infuture versions of Qtopia Phone Edition the user may be able to choose theirpreference for text over icons.<p> <h3> The Context Menu</h3><a name="1-3"></a><p> The Qt::Key_Menu button is used to display a menu of actionspossible in the current application state. The <a href="contextmenu.html">ContextMenu</a> class isa subclass of QPopupMenu that is bound to the Menu button. When theMenu button is pressed, the context menu for the currently focussed widgetwill be displayed. It follows thesame rules as <a href="contextbar.html">ContextBar</a>, so if the current focus widget does not claimthe Menu key or have a context menu, then the ContextMenu or label ofan ancestor will be active.<p> ContextMenu is used identically to QPopupMenu, e.g.<pre> <a href="contextmenu.html">ContextMenu</a> *contextMenu(this); contextMenu->insertItem(tr("Open"), this, SLOT(open())); QAction *a = new QAction(tr("New"), Resource::loadIconSet("filenew"), QString::null, 0, this, 0 ); a->addTo(contextMenu);</pre> <p> <h3> Supporting Qtopia PDA and Qtopia Phone</h3><a name="1-4"></a><p> This section shows the recommended method for writing an applicationwhich can be deployed on both PDAs and phones. For simple applicationsthis usually means supporting a menu bar and toolbars on the PDA anda <a href="contextmenu.html">ContextMenu</a> on the phone. More complex applications may considerdifferent data views and dialog layouts.<p> Consider the code commonly used to construct the user interface:<pre>MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f){ // Create menu QToolBar *bar = new QToolBar(this); bar->setHorizontalStretchable(TRUE); QMenuBar *menubar = new QMenuBar(bar); QPopupMenu *fileMenu = new QPopupMenu(menubar); // Create toolbar fileTools = new QToolBar(this); // Create actions and add to the menu/toolbar newAction = new QAction(tr("New"), Resource::loadIconSet("filenew"), QString::null, 0, this, 0 ); connect(newAction, SIGNAL(activated()), this, SLOT(new())); newAction->addTo(fileMenu); newAction->addTo(fileTools); openAction = new QAction(tr("Open"), Resource::loadIconSet("fileopen"), QString::null, 0, this, 0 ); connect(openAction, SIGNAL(activated()), this, SLOT(open())); openAction->addTo(fileMenu); openAction->addTo(fileTools); // Create central widget view = new View(this); setCentralWidget(view); // Other initialization}</pre> <p> The same application on a phone will have no menubar or toolbar. It willinstead have a <a href="contextmenu.html">ContextMenu</a> activated by a context key. The above code canbe modified to support both PDA and phone as follows:<pre>MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f){ // Create actions newAction = new QAction(tr("New"), Resource::loadIconSet("filenew"), QString::null, 0, this, 0 ); connect(newAction, SIGNAL(activated()), this, SLOT(new())); openAction = new QAction(tr("Open"), Resource::loadIconSet("fileopen"), QString::null, 0, this, 0 ); connect(openAction, SIGNAL(activated()), this, SLOT(open()));#ifndef QTOPIA_PHONE // Create menu QToolBar *bar = new QToolBar(this); bar->setHorizontalStretchable(TRUE); QMenuBar *menubar = new QMenuBar(bar); QPopupMenu *fileMenu = new QPopupMenu(menubar); // Create toolbar fileTools = new QToolBar(this); // Add actions to menu and toolbar newAction->addTo(fileMenu); newAction->addTo(fileTools); openAction->addTo(fileMenu); openAction->addTo(fileTools);#else // Create context menu contextMenu = new <a href="contextmenu.html">ContextMenu</a>(this); // Add actions to the context menu. contextMenu-><a href="contextmenu.html#addTo">addTo</a>(fileTools); contextMenu-><a href="contextmenu.html#addTo">addTo</a>(fileMenu);#endif // Create central widget view = new View(this); setCentralWidget(view); // Other initialization}</pre> <p> In the above code, all actions are created and then either the menu andtoolbar created and populated, or a context menu populated and created.<p> In larger applications some of the actions available in the PDA versionmay be handled in other ways, e.g. by assigning them to key presses(see QAction::setAccel) ratherthan tool buttons/menu items, or they may be disabled completely if theyare unsuitable for use on a phone.<p> <h3> Input Methods</h3><a name="1-5"></a><p> Text input on a phone is accomplished by input methods. These allow theuser to generate text using, for example, the normal phone keys.Since this can be very limited, hints are used to improve itsuseability. A input method type hint is generated whenever a widgetgets focus. The hint is either:<p> <ol type=1><li> The hint specifically set using <a href="qpeapplication.html#setInputMethodHint">QPEApplication::setInputMethodHint</a>().<li> For QLineEdit and QMultiLineEdit with a QIntValidator, the hintis to Number.<li> The null hint.</ol><p> The hints are presented as text (for future extensibility) to theInput Methods and they respond thusly:<p> <ul><li> For "int", the phone number keys inputcorresponding digits.<li> For "phone", "*" and "#" also work, and conventionsare honoured, such as press-and-hold the "0" key for "+", and the "*" key for "p".<li> For "words", the standard key text associations are used, and a dictionary-lookupis used to guess the desired letter.<li> For "text", the standard key text associations are used, with multiple presses by theuser and used to choose the desired letter.<li> For the null hint, no method is used - keys are passed unchanged.</ul><p> <!-- eof --><p><address><hr><div align="center"><table width="100%" cellspacing="0" border="0"><tr><td>Copyright © 2001-2004 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a><td align="right"><div align="right">Qtopia version 2.0.0</div></table></div></address></body></html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -