[Qt-interest] HTML document + Qt widgets: options ?

Stephen Collyer scollyer at netspinner.co.uk
Fri May 21 10:37:47 CEST 2010


On 21 May 2010 09:14, David Boddie <david.boddie at nokia.com> wrote:

> On Friday 21 May 2010 09:57:40, Stephen Collyer wrote:
> > On 20 May 2010 20:46, Richard Moore <richmoore44 at gmail.com> wrote:
>
> >> I explained the former in this post
> >> http://www.kdedevelopers.org/node/4008
> >>
> >>
> > Thanks. That looks fairly straightforward. However, it's not
> > clear to me how the widget generated by PluginFactory::create()
> > can communicate with the app. outside the HTML in which it
> > is embedded. How does one connect signals from the widget,
> > for example ?
>
> Although it's been a while since I looked at it, I think this might be
> covered in a Qt Quarterly article:
>
>  http://doc.qt.nokia.com/qq/qq26-webplugin.html#bridgingthegap
>
>
Thanks. That's pretty useful in itself, but it doesn't decribe the
case thar I'm interested in. It only shows how to connect an
embedded widget to a JS function in the page.

However, I can see a horrible hack that may work which is
to subclass the widget of interest,  and in PluginFactory::create(),
pass a comms object (a QSignalMapper ?) from the outside
world to the ctor of the subclassed widget. Then use the comms
object to relay signals to the rest of the app. by connecting
the signals of interest in the ctor of the subclassed widget. e.g.

class MyPushButton : public QPushButton
{
..
    MyPushButton::MyPushButton(CommsObject* comms);
..
}

MyPushButton::MyPushButton(CommsObject* comms)
{
    connect(this, SIGNAL(..), comms, SLOT(..));
}

void PluginFactory::create(..)
{
..
    MyPushButton pb = new MyPushButton(comms_object_);
}

CommsObject* PluginFactory::comms()
{
    return comms_object_;
}

-- 
Stephen Collyer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100521/eefa90e9/attachment.html 


More information about the Qt-interest-old mailing list