[Qt-interest] Standard keys in menus
Andreas Pakulat
apaku at gmx.de
Mon Oct 19 19:07:16 CEST 2009
Can you please fix your quoting style? Its really awkward.
On 18.10.09 15:25:58, Scott Aron Bloom wrote:
> Well, the problem is how should the slot be implemented by Qt in a
> generic way? And how should the action decide which widget to connect
> to, for example if you have multiple text edits. This is part of your
> job as app developer - to put the widgets together and connect them to
> create a meaningful application.
>
> Andreas
>
> --
> ---------------
> However, You could say the same thing about buttons for dialogs. And TT
> created the approach of the QButtonBox, where you simply create the
> object, and say what type of buttons you want, then connect to a
> standard set of signals.
Right, but thats not what the OP asks about. He wants the slot connected
to that signal to be "ready-made" and him not worrying about anything
else.
> Its all done ontop of the QButtons/QLayout system, but it makes sure we
> as app developers keep a consistent and compliant (WRT to order) button
> layout
Its a lot easier in that case, because for the ok-button (or
cancel-button) in a dialog there's usually just one thing to do: Call
the "accept()" slot. However for menu actions such as copy/paste/cut
things are a lot more complicated, because Qt cannot know which widget
it should and can apply to as it doesn't know which widgets are in your
mainwindow. It could try to use the object inheritance to find out, but
then maybe you want those items to react only on specific widgets.
> I would love to see a menu system created on top of QMenu/QMainWindow,
> where you added standard "menu actions" to the object, and it
> constructed the menubar, its child menus, and the actions...
>
> Then we could either have a QSignalMapper type of response, or a simple
> "menuItemActivated( enum QStandardMenuItem )" type of signal..
>
> Something like
>
> menuSystem()->addAction(QMenuSystem::FileOpen);
> menuSystem()->addAction(QMenuSystem::FileSave);
> menuSystem()->addAction(QMenuSystem::FileClose);
>
> connect( menuSystem(), SIGNAL( menuItemActivated( QStandardMenuIte ) ),
> this, SLOT( slotMenuItemActivated( QStanardMenuItem ) )
As I said above this wouldn't solve the OP's problem (as I understood
it), what he wants is not to have to write this slot:
> ::slotMenuItemActivated( QStanardMenuItem item )
> {
> switch( item )
> case FileOpen: this->fileOpen(); return
> ...
> }
Andreas
--
Your heart is pure, and your mind clear, and your soul devout.
More information about the Qt-interest-old
mailing list