Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

Q3Signal Class

TheQ3Signal class can be used to send signals for classes that don't inheritQObject.More...

Header:#include <Q3Signal>
Inherits:QObject

Public Functions

Q3Signal(QObject * parent = 0, const char * name = 0)
~Q3Signal()
voidactivate()
boolconnect(const QObject * receiver, const char * member)
booldisconnect(const QObject * receiver, const char * member = 0)
voidsetValue(const QVariant & value)
QVariantvalue() const
  • 29 public functions inherited fromQObject

Additional Inherited Members

  • 1 property inherited fromQObject
  • 1 public slot inherited fromQObject
  • 1 signal inherited fromQObject
  • 7 static public members inherited fromQObject
  • 8 protected functions inherited fromQObject

Detailed Description

TheQ3Signal class can be used to send signals for classes that don't inheritQObject.

If you want to send signals from a class that does not inheritQObject, you can create an internalQ3Signal object to emit the signal. You must also provide a function that connects the signal to an outside object slot. This is how we used to implement signals in Qt 3'sQMenuData class, which was not aQObject. In Qt 4, menus contain actions, which areQObjects.

In general, we recommend inheritingQObject instead.QObject provides much more functionality.

You can set a singleQVariant parameter for the signal withsetValue().

Note thatQObject is aprivate base class ofQ3Signal, i.e. you cannot call anyQObject member functions from aQ3Signal object.

Example:

#include <q3signal.h>class MyClass{public:    MyClass();~MyClass();void doSomething();void connect(QObject*receiver,constchar*member);private:Q3Signal*sig;};MyClass::MyClass(){    sig=newQ3Signal;}MyClass::~MyClass(){delete sig;}void MyClass::doSomething(){// ... does something    sig->activate();// emits the signal}void MyClass::connect(QObject*receiver,constchar*member){    sig->connect(receiver, member);}

Member Function Documentation

Q3Signal::Q3Signal(QObject * parent = 0, constchar * name = 0)

Constructs a signal object calledname, with the parent objectparent. These arguments are passed directly toQObject.

Q3Signal::~Q3Signal()

Destroys the signal. All connections are removed, as is the case with allQObjects.

void Q3Signal::activate()

Emits the signal. If the platform supportsQVariant and a parameter has been set withsetValue(), this value is passed in the signal.

bool Q3Signal::connect(constQObject * receiver, constchar * member)

Connects the signal tomember in objectreceiver. Returns true if the connection is successful.

See alsodisconnect() andQObject::connect().

bool Q3Signal::disconnect(constQObject * receiver, constchar * member = 0)

Disonnects the signal frommember in objectreceiver. Returns true if the connection existed and the disconnect was successful.

See alsoconnect() andQObject::disconnect().

void Q3Signal::setValue(constQVariant & value)

Sets the signal's parameter tovalue

See alsovalue().

QVariant Q3Signal::value() const

Returns the signal's parameter

See alsosetValue().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp