Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, April 2007
[4.2.2] SIGNAL / SLOT with QObject* progressReceiver, const char* progressSlot


Message 1 in thread

Hi Qtees,

I wonder how I can connect a signal to a slot when the slot's receiver
and name are given by QObject* progressReceiver and const char*
progressSlot. I tried to connect like this:
   
   connect(ABC, SIGNAL(someMethod(unsigned int)), progressReceiver,
progressSlot);

... with "progressSlot" being "someMethod(unsigned int)". What I got is
this:

  Object::connect: Use the SLOT or SIGNAL macro to connect
XYZWidget::someMethod(unsigned int)


Does anybody know how to do that? Further, this is in the "run" method
of a class derived from QThread. The progressReceiver is an object
"outside" this tread. Therefore I even tried to call "exec()", but that
stopped the tread from execution.


Thanks in advance,
r.

--------------------------------------------------------------------
  Rene Kaiser
  Institute of Information Systems & Information Management
  JOANNEUM RESEARCH Forschungsgesellschaft mbH
  Steyrergasse 17, A-8010 Graz, AUSTRIA

  phone:  +43-316-876-1173                   fax: +43-316-876-1191
  web:    http://www.joanneum.at/iis
  e-mail: mailto:rene.kaiser@xxxxxxxxxxx
-------------------------------------------------------------------- 

--
 [ signature omitted ] 

Message 2 in thread

Kaiser, Rene wrote:
> Hi Qtees,
>  [...]
>    
>    connect(ABC, SIGNAL(someMethod(unsigned int)), progressReceiver,
> progressSlot);
> 
 Did you forgot the SLOT( ... ) here ?!

connect(ABC, SIGNAL(someMethod(unsigned int)), progressReceiver,
 SLOT( progressSlot(unsigned int) ) );

-- 
 [ signature omitted ] 

Message 3 in thread

Proplem here is that the slot's signature comes from the method's parameter, currently "const char* progressSlot". I have no idea how to call connect with that.

Any ideas anyone?

r.
 

-----Ursprüngliche Nachricht-----
Von: Michael Sprauer [mailto:Michael.Sprauer@xxxxxxxxxxxxxxxxxx] 
Gesendet: Donnerstag, 12. April 2007 14:27
An: Qt Interest
Betreff: Re: [4.2.2] SIGNAL / SLOT with QObject* progressReceiver, const char* progressSlot

Kaiser, Rene wrote:
> Hi Qtees,
>  [...]
>    
>    connect(ABC, SIGNAL(someMethod(unsigned int)), progressReceiver, 
> progressSlot);
> 
 Did you forgot the SLOT( ... ) here ?!

connect(ABC, SIGNAL(someMethod(unsigned int)), progressReceiver,  SLOT( progressSlot(unsigned int) ) );

--
 [ signature omitted ] 

Message 4 in thread

Von: "Kaiser, Rene" <Rene.Kaiser@xxxxxxxxxxx>
> 
> Proplem here is that the slot's signature comes from the method's
> parameter, currently "const char* progressSlot". I have no idea how to call connect
> with that.
> 
> Any ideas anyone?
> 
I would say: Read the docs!
Why should it be possible to connect a signal which emits an unsigned int to a slot which needs const char* ? How should this work?

Christian
-- 
 [ signature omitted ] 

Message 5 in thread

I would say: Read the ...   : )

Joking apart, there seems to be a misunderstanding. As I thought I had explained in the original post, the SLOT I want to connect to doesn't have a "const char*" parameter, but the "const char* progressSlot" value contains the signature of the slot, e.g. "progressSlot(uint)".

I want to do literally the same as the QMenu::addAction method (see below). But what I get is something like this:

  Object::connect: Use the SLOT or SIGNAL macro to connect XYZWidget::someMethod(unsigned int)

As said, the connect happens to be inside the run method of a class derived from QThread. I hope that's not the reason for this problem.


Regards,
r.

########################################################################

QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut)
{
    QAction *action = new QAction(text, this);
#ifdef QT_NO_SHORTCUT
    Q_UNUSED(shortcut);
#else
    action->setShortcut(shortcut);
#endif
    QObject::connect(action, SIGNAL(triggered()), receiver, member);  <--- uses the QObject and const char* parameters!
    addAction(action);
    return action;
}

########################################################################
 

-----Ursprüngliche Nachricht-----
Von: Christian Ehrlicher [mailto:Ch.Ehrlicher@xxxxxx] 
Gesendet: Donnerstag, 12. April 2007 14:46
An: qt-interest@xxxxxxxxxxxxx
Cc: Kaiser, Rene
Betreff: AW: [4.2.2] SIGNAL / SLOT with QObject* progressReceiver, const char* progressSlot

Von: "Kaiser, Rene" <Rene.Kaiser@xxxxxxxxxxx>
> 
> Proplem here is that the slot's signature comes from the method's 
> parameter, currently "const char* progressSlot". I have no idea how to 
> call connect with that.
> 
> Any ideas anyone?
> 
I would say: Read the docs!
Why should it be possible to connect a signal which emits an unsigned int to a slot which needs const char* ? How should this work?

Christian
--
 [ signature omitted ] 

Message 6 in thread

Kaiser, Rene schrieb:
> I would say: Read the ...   : )
> 
> Joking apart, there seems to be a misunderstanding. As I thought I had explained in the original post, the SLOT I want to connect to doesn't have a "const char*" parameter, but the "const char* progressSlot" value contains the signature of the slot, e.g. "progressSlot(uint)".
> 
> I want to do literally the same as the QMenu::addAction method (see below). But what I get is something like this:
> 
>   Object::connect: Use the SLOT or SIGNAL macro to connect XYZWidget::someMethod(unsigned int)
> 
> As said, the connect happens to be inside the run method of a class derived from QThread. I hope that's not the reason for this problem.
> 
the SLOT-macro is defined as

#define SLOT(a)                "1"#a

So your char* needs to be "1someMethod(uint)" or better create your 
char* with the SLOT-macro instead.

Christian

--
 [ signature omitted ]