Translations:Development/Tutorials/Qt4 Ruby Tutorial/Chapter 08/14/ru: Difference between revisions

From KDE TechBase
(Created page with "Слот '''<tt>setRange()</tt>''' устанавливает диапазон возможных значений ползунка '''<tt>LCDRange</tt>'''. Поскольку м...")
 
(No difference)

Latest revision as of 17:51, 2 July 2011

Information about message (contribute)
This message has no documentation. If you know where or how this message is used, you can help other translators by adding documentation to this message.
Message definition (Development/Tutorials/Qt4 Ruby Tutorial/Chapter 08)
The '''<tt>setRange()</tt>''' slot sets the range of the slider in the '''<tt>LCDRange</tt>'''. Because we have set up the [http://doc.qt.nokia.com/latest/qlcdnumber.html QLCDNumber] to always display two digits, we want to limit the possible range of '''<tt>minVal</tt>''' and '''<tt>maxVal</tt>''' to avoid overflow of the [http://doc.qt.nokia.com/latest/qlcdnumber.html QLCDNumber]. (We could have allowed values down to -9 but chose not to.) If the arguments are illegal, we use Qt's [http://doc.qt.nokia.com/latest/qtglobal.html#qWarning QtGlobal::qWarning()] function to issue a warning to the user and return immediately. [http://doc.qt.nokia.com/latest/qtglobal.html#qWarning QtGlobal::qWarning()] is a '''<tt>printf</tt>'''-like function that by default sends its output to '''<tt>$stderr</tt>'''. If you want, you can install your own handler function using [http://doc.qt.nokia.com/latest/qtglobal.html#qInstallMsgHandler QtGlobal::qInstallMsgHandler()].

Слот setRange() устанавливает диапазон возможных значений ползунка LCDRange. Поскольку мы настроили QLCDNumber на показ двух цифр, нужно ограничить диапазон значений minVal и maxVal, чтобы не происходило переполнения QLCDNumber. (Можно было разрешить отрицательные значения до -9, но мы решили этого не делать.) Если аргументы слота недопустимы, мы используем функцию Qt QtGlobal::qWarning() для того, чтобы сообщить пользователю об ошибке. QtGlobal::qWarning() работает аналогично printf и по умолчанию выводит сообщение в $stderr. Можно установить свой обработчик сообщений с помощью QtGlobal::qInstallMsgHandler().