[Kmymoney-devel] Context menu in Qt4 list widgets
Thomas Baumgart
thb at net-bembel.de
Tue Mar 2 09:08:37 CET 2010
On Tuesday 02 March 2010 08:28:31 Cristian Oneţ wrote:
> În data de Marți 02 Martie 2010 02:52:56 Alvaro Soliverez a scris:
> > On Mon, Mar 1, 2010 at 11:16 AM, Cristian Oneţ <onet.cristian at gmail.com>
>
> wrote:
> > > On Mon, Mar 1, 2010 at 2:53 PM, Alvaro Soliverez <asoliverez at gmail.com>
>
> wrote:
> > >> Hello,
> > >> does anyone have experience with custom context menus in Qt4?
> > >> I'm porting the Payees view to full Qt4 mode, and I can't get the
> > >> custom context menu to activate.
> > >>
> > >> I'm setting the contextMenuPolicy and connecting the signal to the
> > >> method which opens the context menu for the selected item.
> > >>
> > >> I'm thinking of deactivating altogether and replacing it with a button
> > >> bar like the budget list, but first I wanted it to work as-is.
> > >
> > > Take a look at kmymoneyaccounttreeview.cpp, there a Qt4 widget uses
> > > the custom context menu signal and it works.
> >
> > Hmmmm, how did you get away with the signal and the slot having the
> > same name? :D
Easy, because the signal method lives in QWidget (which is used by the base
QTreeView-Code) and the slot just overrides this method and lives in our own
widget. That way, moc knows about the signal and the slot and simply uses the
same names. You will have trouble though to emit that signal from within our
code. It simply will not work (as you call the slot method).
> I didn't know there was such a restriction, that's how.
But we can rename our slot to whatever we like.
--
Regards
Thomas Baumgart
GPG-FP: E55E D592 F45F 116B 8429 4F99 9C59 DB40 B75D D3BA
-------------------------------------------------------------
BTW, just the planning of the test cases helped me
to improve the code a lot. -- Alvaro Soliverez
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 224 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kmymoney-devel/attachments/20100302/474494ef/attachment-0001.sig
More information about the KMyMoney-devel
mailing list