[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Send arguments to slot
From:       Ingo Krabbe <ikrabbe.ask () web ! de>
Date:       2006-03-06 7:24:23
Message-ID: 200603060824.23216.ikrabbe.ask () web ! de
[Download RAW message or body]

Am Montag, 6. März 2006 14:42 schrieb Joaquín Fernández Quiles:
> > On Saturday 04 March 2006 21:33, Christoffer Brodd-Reijer wrote:
> >> I now want to show a popupmenu asking the user if he wants to copy or
> >> move the file(s), just like Konqueror. So I moved all the code from
> >> slotDrop() to a new slot, called copyMoveFile() and change the
> >> slotDrop() so it instead shows a popupmenu with the different
> >> alternatives. Since copying and moving is almost the same (except for
> >> one line) I thought I could just send an int as an argument which
> >> should be 1 or 2 for copy or move.
>
> For this i have used QActionGroup. You must add the actions to this class
> and use the signal "void triggered (QAction *action)" then you can verify
> the action selected by the user. I suppose that you have 2 actions:
> actCopyFile and actMoveFile:
>

Yes, for this you used QActionGroup, for something else, you used something 
else.

I find this problem is quite abstract and well known to the whole realm of C++ 
and other structured programming, since it has to do with hiding objects 
inside of classes and to keep variables as local as possible, which is a good 
design decision, of course.  On the other hand you have qApp, the application 
pointer as a global reference.

My solution is to write a simply descendant of QApplication and add a simple 
object map to it, that contains opaque objects:

class MyApp: public QApplication
{
	std::map<std::string,void*> object_map;
public:
	void* get_value( const char* name );
	void set_value( const char* name, void* value );
};

If you take care of your variable's memory you can use these application 
values in any surrounding and map them to objects, properties or whatever.

bye ingo
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic