Qt-jambi-interest Archive, August 2006
Slots not autoconnecting, focus not changing, keyboard not working
Message 1 in thread
Hi,
I have come across some problems. Most unusual. This is how it started. I
want to be able to click a button, do some stuff and then position the focus
unto some other button for conveenions for the use. I'm using juic with ui
files, for example, if the ui file defines to PushButtons, pb1 and pb2:
import ui.Ui_Example;
import com.trolltech.qt.gui.*;
public Example extends QWidget
{
Ui_Example ui = new Ui_Example();
public Example()
{
super();
ui.setupUi(this);
}
private void on_pb1_clicked() // Note 1
{
// Do "stuff", or pretend to do something
ui.pb2.setFocus(); // Note 2
}
private void on_pb1_pressed() // Note 3
{
// Same as above
}
}
Note 1:
Clicking on pb1 works however if one were to tab to the button and press
<enter> nothing will happen. The button doesn't respond to keyboard events,
specificly <enter>
Note 2:
Changing focus does work, but there is no visual confirmation that there has
been a change in focus, unless one tabbed to the button (this may just be the
default style on unix not showing a change?) however pb2 does not respond to
keyboard events, as stated in Note 1
Note 3:
This does not work:
[java] Exception in thread "main" java.lang.RuntimeException: Don't know how
to autoconnect to: com.trolltech.qt.gui.QAbstractButton.pressed
[java] at com.trolltech.qt.QtJambiUtils.tryConnect(QtJambiUtils.java:280)
[java] at
com.trolltech.qt.QtJambiUtils.connectSlotsByName(QtJambiUtils.java:312)
[java] at ui.Ui_MemberManager.setupUi(Unknown Source)
[java] at widgets.MemberManager.<init>(Unknown Source)
[java] at Main.<init>(Unknown Source)
[java] at Main.main(Unknown Source)
[java] Java Result: 1
The same goes for QSpinBox.editingFinished. I do not know what is going on
here?
Those are the problems that I am having. Any advice on the proper way of
handling ui and juic? I have stuck them all into their own ui package and
used it the same as above. It works quite well.
And I did try to implement QAbstractItemModel and succeeded in crashing java,
with a core dump of 250mb. I read through all the documentation about doing
such things and looked through some of the examples that come with Qt Jambi
but no luck. So I'm trying a different approach using a plain QWidget and
QGridLayout... Propable some really blond mistakes, I noticed a few, but
bitten once, twice shy.
Thank you again for a very well done Qt Jambi. I'm impressed that it can
actually work on FreeBSD! (the linux version). Hint, hint... :-)
Keep up the good work
David
Message 2 in thread
Hi, David.
David Naylor wrote:
>Note 1:
>Clicking on pb1 works however if one were to tab to the button and press
><enter> nothing will happen. The button doesn't respond to keyboard events,
>specificly <enter>
>
>
Hitting <ENTER> in a dialog box will activate the default button of the
dialog. <SPACEBAR> however, will give you a clicked signal for the
button that has keyboard focus.
>Note 2:
>Changing focus does work, but there is no visual confirmation that there has
>been a change in focus, unless one tabbed to the button (this may just be the
>default style on unix not showing a change?) however pb2 does not respond to
>keyboard events, as stated in Note 1
>
>
Yes, this is style dependent. If you use e.g. Motif, you will see visual
indication of the current keyboard focus all the time, but in styles
such as Plastique, the keyboard focus rectangle will only be visible
once you've begun navigating with the keyboard.
>Note 3:
>This does not work:
>[java] Exception in thread "main" java.lang.RuntimeException: Don't know how
>to autoconnect to: com.trolltech.qt.gui.QAbstractButton.pressed
>[java] at com.trolltech.qt.QtJambiUtils.tryConnect(QtJambiUtils.java:280)
>[java] at
>[...]
>
>
This is a bug, I'm afraid. It seems it will be problematic to
autoconnect signals that do not take any parameters. It will be fixed
for the next release, but until then, you will unfortunately have to
connect these signals explicitly.
ui.pb1.pressed.connect(this, "some_slot()");
"some_slot()" should, in this case, avoid the pattern of method names
for autoconnections, since you would then still get the exception.
>And I did try to implement QAbstractItemModel and succeeded in crashing java,
>with a core dump of 250mb. I read through all the documentation about doing
>such things and looked through some of the examples that come with Qt Jambi
>but no luck. So I'm trying a different approach using a plain QWidget and
>QGridLayout... Propable some really blond mistakes, I noticed a few, but
>bitten once, twice shy.
>
>
I would be interested in seeing what you did that made Qt Jambi crash in
this way. Would you be able to send me a small example that reproduces
the crash?
However, if you are still interested in trying your hand at it, I just
thought I'd mention the class
com.trolltech.demos.imageviewer.ImageTableModel as an example of how to
implement a QAbstractItemModel subclass. If you haven't already looked
at it, maybe it would be helpful to you.
>Thank you again for a very well done Qt Jambi.
>
>
Thank you for using Qt Jambi, and for reporting these problems :-) Good
luck and please post again if you have further issues!
-- Eskil