index.lxp@lxpwrap=x3581_252ehtm.htm

来自「GUI Programming with Python」· HTM 代码 · 共 755 行 · 第 1/2 页

HTM
755
字号
CLASS="MEDIAOBJECT"><P><DIVCLASS="CAPTION"><P>A gentle warning</P></DIV></P></DIV><DIVCLASS="MEDIAOBJECT"><P><DIVCLASS="CAPTION"><P>A dire warning</P></DIV></P></DIV><DIVCLASS="MEDIAOBJECT"><P><DIVCLASS="CAPTION"><P>About your application</P></DIV></P></DIV><DIVCLASS="MEDIAOBJECT"><P><DIVCLASS="CAPTION"><P>About Qt</P></DIV></P></DIV></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2">QTabDialog</A></H2><P>One of the best ways to organize a        multitude of options is to group them together and show the        user only the pertinent set, hiding the rest between tabs.        Usability studies have shown that a moderate number of tabs,        presented in a single row showing all available tabs at one        time, promotes the greatest usability. Twenty tabs in three        rows confuse the user; one scrolling row of twenty tabs        irritates the user. I have once used tabs within tabs myself,        but it's not something I'd recommend.        </P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2">QWizard</A></H2><P>Complex, infrequent actions are        eminently suited to the wizard approach. A wizard is a set of        pages that guide the user through a certain path. The user        need not visit all pages, and there might be more than one        possible path. Avoid using wizards where tab pages might be        more suited (when there are many options but no clear        progression through the steps of a complex action).        </P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2">QFileDialog</A></H2><P>The first of the Qt standard dialogs is the        <TTCLASS="CLASSNAME">QFileDialog</TT>. The file dialog can be        extended with custom icons, toolbuttons and extra widgets.        In its default format it is        extremely easy to use: just call one of the predefined class        methods that return the name of a directory or file, such as        <TTCLASS="FUNCTION">getOpenFileName()</TT> or        <TTCLASS="FUNCTION">getOpenFileNames()</TT>.        </P><DIVCLASS="EXAMPLE"></A><P><B>Example 10-15. fragment from dialogs.py - opening a file dialog          </B></P><PRECLASS="PROGRAMLISTING">...    def slotFile(self):        filename=QFileDialog.getOpenFileName("", "*.py", self, "FileDialog")...        </PRE></DIV><DIVCLASS="MEDIAOBJECT"><P><DIVCLASS="CAPTION"><P>The Qt File dialog</P></DIV></P></DIV></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2">QFontDialog</A></H2><P>A useful dialog,        <TTCLASS="CLASSNAME">QFontDialog</TT> lets the user select a font        by giving parameters for font name, style, size, effects and        script &#8212; this last parameter being the encoding of the        font, such as Unicode. Just as with        <TTCLASS="CLASSNAME">QFileDialog</TT>,        <TTCLASS="CLASSNAME">QFontDialog</TT> provides a set of class        methods that return the selected value, in this case a tuple        containing a <TTCLASS="CLASSNAME">QFont</TT> object and a boolean        value that indicates whether OK or Cancel was pressed..        </P><P>Of course, with Qt3, you no longer set        the desired encoding, but rather the script - Greek, Tamil, or        whatever you want.</P><DIVCLASS="EXAMPLE"></A><P><B>Example 10-16. fragment from dialogs.py - opening a font dialog          </B></P><PRECLASS="PROGRAMLISTING">...    def slotFont(self):        (font, ok) = QFontDialog.getFont(self, "FontDialog")...          </PRE></DIV><DIVCLASS="MEDIAOBJECT"><P><DIVCLASS="CAPTION"><P>The Qt font dialog</P></DIV></P></DIV></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2">QColorDialog</A></H2><P><TTCLASS="CLASSNAME">QColorDialog</TT>        provides a standard dialog for color selection. An interesting        addition to this class is that you ask it to store a set of        custom colors. This set will be kept during the lifetime of        the application, and you can store those colors in a        configuration file and restore them when the app is restarted.        You can ask the color dialog either for a        <TTCLASS="CLASSNAME">QColor</TT> object, or for a set of RGB        values, encapsulated in a <TTCLASS="CLASSNAME">QRgb</TT> object.        In contrast with <TTCLASS="CLASSNAME">QFileDialog</TT>, which is        extensible, or <TTCLASS="CLASSNAME">QFontDialog</TT>, which        really suffices, <TTCLASS="CLASSNAME">QColorDialog</TT> provides        just barely enough for simple color selection, but won't do        for more complex graphics applications (with which you might        want to implement something that works with HSV values, or        with a color wheel).        </P><DIVCLASS="EXAMPLE"></A><P><B>Example 10-17. fragment from dialogs.py - opening a color dialog          </B></P><PRECLASS="PROGRAMLISTING">...    def slotColor(self):        color=QColorDialog.getColor(QColor("linen"), self, "ColorDialog")...          </PRE></DIV><DIVCLASS="MEDIAOBJECT"><P><DIVCLASS="CAPTION"><P>The Qt Color dialog</P></DIV></P></DIV></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2">QInputDialog</A></H2><P>You can use        <TTCLASS="CLASSNAME">QInputDialog</TT> to ask the user for a        simple, single value. This value can be of the following type:        text, integer, double, or an item from a listbox. Frankly,        I've never had a need for these. The open remote location        dialog in browsers like Opera or Netscape are a common        example.        </P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2">QProgressDialog</A></H2><P>The        <TTCLASS="CLASSNAME">QProgressDialog</TT> is a useful little        dialog that can be used to inform the user that a certain        action will be taking a lot of time. If the operation of the        dialog is meant to block the whole application, use a modal        <TTCLASS="CLASSNAME">QprogressDialog</TT>. If the operation won't        block the entire application, then it's possible to use a        modeless <TTCLASS="CLASSNAME">QProgressDialog</TT>, but it may be        more effective to use a <TTCLASS="CLASSNAME">QProgressBar</TT> in        the statusbar of the application.        <TTCLASS="CLASSNAME">QProgressDialog</TT> is based on the        <TTCLASS="CLASSNAME">QSemiModal</TT> class.      </P></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><A accesskey="P" href="index.lxp@lxpwrap=x3410_252ehtm.htm">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><A accesskey="H" href="index.lxp@lxpwrap=book1_252ehtm">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><A accesskey="N" href="index.lxp@lxpwrap=x3738_252ehtm.htm">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Layout managers</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><A accesskey="U" href="index.lxp@lxpwrap=c2591_252ehtm.htm">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Qt Utility classes and their Python equivalents</TD></TR></TABLE></DIV></BODY></HTML>      </td>      </tr>      </table>      </td>    </tr>  </table>      

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?