PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 890 - Add signal connection example for valueChanged(int) on QSpinBox to the docs
: Add signal connection example for valueChanged(int) on QSpinBox to the docs
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: Documentation
: HEAD
: PC Linux
: P4 enhancement
Assigned To: Hugo Parente Lima
:
:
:
  Show dependency treegraph
 
Reported: 2011-06-17 22:37 EEST by Thomas Perl
Modified: 2011-07-22 22:12 EEST (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Perl 2011-06-17 22:37:53 EEST
For most use cases, developers probably want to have the int-typed valueChanged
signal, and not the unicode one (which is the default when using
.valueChanged.connect() on a QSpinBox object). I propose to add the following
example to the documentation page of QSpinBox to show how to connect the
valueChanged(int) signal, i.e.:

    spinbox.connect(SIGNAL('valueChanged(int)'), callback_int) 

The documentation page where I think this would fit is the following:

    http://www.pyside.org/docs/pyside/PySide/QtGui/QSpinBox.html

======
from PySide.QtCore import *
from PySide.QtGui import *

import sys

app = QApplication(sys.argv)

def callback_int(value_as_int):
    print 'int value changed:', repr(value_as_int)

def callback_unicode(value_as_unicode):
    print 'unicode value changed:', repr(value_as_unicode)

spinbox = QSpinBox()
spinbox.connect(SIGNAL('valueChanged(int)'), callback_int) 
spinbox.valueChanged.connect(callback_unicode) 
spinbox.show()

sys.exit(app.exec_())
======

The reason for this proposal is because the question came up on IRC and the
answer wasn't obvious at first, because most signal examples only show the
.<signalname>.connect() method without the parameter type signature.
Comment 1 Thomas Perl 2011-06-17 22:44:35 EEST
Maybe even this as a better example to demonstrate what use the unicode type
has for a widget that basically has numeric values as only possible data range
would be to add a call to .setSpecialValueText() below the call to the QSpinBox
constructor, like this:

    [...]
    spinbox = QSpinBox()
    spinbox.setSpecialValueText('Automatic')
    [...]
Comment 2 Hugo Parente Lima 2011-07-21 22:08:08 EEST
Examples added using new style signals for both signals in commit:

pyside/b2ec5cf60752e2ce8f9950fde809d841ad8e6793

The online docs will be updated when the new release arrives.
Comment 3 renato filho 2011-07-22 22:12:47 EEST
release 1.0.5