Reply
Thread Tools
fpp's Avatar
Posts: 2,853 | Thanked: 968 times | Joined on Nov 2005
#1
Hi,

I've read quite a few threads here and also some pages on the Wiki, but nobody else seems to have the problem I'm seeing, so I must be doing something stupid :-)

I have a very simple app prototype, which I code on the desktop using Designer and eric4, then copy to the N900. It looks strange on the PC but OK on the N900 thanks to all the tips I found here (stacked windows etc.).

It also works as expected on the PC, and almost so on the N900 except for one thing: the toolbar. It's a very plain toolbar with two buttons using QActions, all done in Designer.

The toolbar shows up on the N900, the buttons can be pressed, but they don't do anything (ie, slots are never called).

The signals are bound by eric4 in the usual "connectSlotsByName" way. Is this not supposed to work in Fremantle ? I've read the Qt-for-Maemo5 platform notes and they don't mention toolbars.

Is there something special/different I need to do to make this work on both platforms ?

TIA,
fp

Edit: just tried binding the same QActions to a menuBar, which translates to a "system menu" in Maemo. Same result: menu shows with its entries, is interactive, but doesn't do anything.

So it's not an issue with the toolbar or menu, probably more with the signal/slots...
__________________
maemo blog

Last edited by fpp; 2010-08-23 at 18:36.
 
fpp's Avatar
Posts: 2,853 | Thanked: 968 times | Joined on Nov 2005
#2
Okay, found the "what" but not the "why"... I don't quite know what to make of this, but I'll write it down here in case it happens to someone else.

So, after ruling out toolbars and menus, I looked into signals and slots, specifically the "dialog code" generated by eric4 from the Designer .ui file.

For QActions, eric4 offers to generate code stubs for a number of signals, the first of which is "activated()". Checking this for an action named "Open" creates a stub slot method, say in mainwindow.py, named:

on_actionOpen_activated(self):

Then in the Python version of the UI file also generated by eric4 (Ui_mainwindow.py) is the magic command:

QtCore.QMetaObject.connectSlotsByName(MainWindow)

This automagically connects the "activated()" signal of the "actionOpen" object to the slot above.

I've used this technique in several previous projects before and never had a problem with it, at least under Windows. But under Maemo5 it doesn't work. Not even if I explicitly connect signal and slot (it then fires twice in Windows, logically, but still not in Maemo).

On a hunch I looked at the (Py)Qt documentation for QAction - which I'd never had to do before because everything was automated by Designer/eric4.

And the strange thing is, if I read correctly, QActions have an "activate()" method, but no "activated()" signal... Their only signals are: changed(), hovered(), toggled(), triggered()... the latter being described as "emitted when an action is activated by the user". Duh.

So I changed the slot name to on_actionOpen_triggered(), and of course now the code works both under XP and Maemo...

Still, I'm left with more questions than I started with:

- is eric4 wrong about QAction signals ?
- if so, why does it work under Windows ?
- else is it a specific Qt/PyQt bug in Maemo ?
- or a known difference between Windows and Linux window managers ?
etc.

Any ideas ? :-)
__________________
maemo blog

Last edited by fpp; 2010-08-23 at 18:36.
 
fpp's Avatar
Posts: 2,853 | Thanked: 968 times | Joined on Nov 2005
#3
No ideas ? Or are all the PyQt devs out to pasture ? :-)
__________________
maemo blog
 
fpp's Avatar
Posts: 2,853 | Thanked: 968 times | Joined on Nov 2005
#4
Okay, since I started this I might as well add the answer I got from the PyQt mailing list :

> The activated() signal is a "Qt 3 support member" of QAction:
> *http://doc.qt.nokia.com/latest/qaction-qt3.html
> This means that it is available if Qt has been built to contain code to
> support APIs in Qt 3, to help people port applications from Qt 3 to Qt 4.
> I guess the version of Qt for Maemo doesn't contain this code, so it won't
> work.

This thankfully solves the "mystery" and answers all my questions :

- most ready-built PyQt packages for desktops (Windows and probably Linux too) are compiled with the Qt3-compatibility options, so "activated" works,

- PyQt on Mameo is not, probably for space/performance reasons, so only "triggered" is recognized,

- eric4 is not plain wrong in proposing "activated" as a signal for QAction, but neither is it marked as deprecated in favour of "triggered".

Whew :-)
__________________
maemo blog
 

The Following 3 Users Say Thank You to fpp For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 23:01.