Qt Slot Return Value

  • Status:Reported
  • Resolution: Unresolved
  • Fix Version/s: None
  • Labels:
  1. Qt Slot Return Value Guide
  2. Qt Slot Return Value
  1. Traditional syntax: SIGNAL and SLOT QtCore.SIGNAL and QtCore.SLOT macros allow Python to interface with Qt signal and slot delivery mechanisms. This is the old way of using signals and slots. The example below uses the well known clicked signal from a QPushButton. The connect method has a non python-friendly syntax.
  2. The first element of the array is the return value. In our example it is 0 because the return value is void. The 3rd parameter passed to activate is the signal index (0 in that case).

The return value of the member function call is placed in ret. If the invocation is asynchronous, the return value cannot be evaluated. You can pass up to ten arguments (val0, val1, val2, val3, val4, val5, val6, val7, val8, and val9) to the member function. QGenericArgument and QGenericReturnArgument are internal helper classes.

The following program reproduces the issue:

Qt Slot Return Value Guide

When I run that program , I get the following output to stdout:

After the sections are resized from 105 (which I assume is their default value) to 210 and 196, signal sectionResized is emitted twice, once for section 0 and once for section 1. You can see that in the first call of the slot connected to that signal, sectionSize(0) and sectionPosition(1) return wrong values. In the second call of the slot, sectionSize(1) returns the wrong value. This behavior occurs not only during the initialization, but also when sections are resized at a later time (as long as sectionResizeMode is ResizeToContents), as attached file example.cpp demonstrates.

I would expect that when sectionResized is emitted, at least sectionSize(logicalIndex) would return the new value. The fact that it doesn't is surprising and can lead to hard to find bugs.

The issue seems to be in QHeaderViewPrivate::resizeSections. In that method, there is a loop that takes care of updating SectionItem objects and emitting signal sectionResized. It emits the signal for section with visual index i in its ith iteration, but it updates the corresponding SectionItem object in a later iteration, after it has reached a section with a different new length (if there is no such section, the SectionItem object is updated after the loop is finished). Therefore, the SectionItem object still contains outdated values when signal sectionResized is emitted for the corresponding section.

Attachments

Gerrit Reviews

No reviews matched the request. Check your Options in the drop-down menu of this sections header.

Qt Slot Return Value

Assignee:
Qt Quick and Widgets Team
Reporter:
Jernej Krempuš
Votes:
0Vote for this issue
Watchers:
1Start watching this issue
Qt Slot Return Value

Any help with this would be appreciated, including hints on how to debug further.

The pyqtSlot decorator takes a result as one of the parameters. However, I'm lost as to how to use it. Here's code to replicate my minimal problem.

@
import sys

from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject

class TestSlot( QObject ):

app = QApplication( sys.argv )

Qt Slot Return Value

w = TestSlot()
w.newTrigger.connect( w.myTestFunction )

the_return_val = w.doIt()
print 'Doit return value: %s' % the_return_val
@

The results from this are:
@➜ python testme.py
Call: doIt
Call: myTestFunction
emit return val: None
Doit return value: None
@

Where is my return value?