Qt Slot Derived Class
We bake cookies in your browser for a better experience. Using this site means that you consent. QObject is the most basic class in Qt. Most of classes in Qt inherit from this class. QObject provides some very powerful capabilities like: object name: you can set a name, as a string, to an object and search for objects by names. Parenting system (described in the following section) signals and slots (described in the next chapter) event.
I’ve been using Qt for several years now in a couple different projects. Only today did I learn about QMetaObject::connectSlotsByName.
QWidget class, derived from QObject and QPaintDevice classes is the base class for all user interface objects. QDialog and QFrame classes are also derived from QWidget class. They have their own sub-class system. Here is a select list of frequently used widgets. Detailed Description. The QObject class is the base class of all Qt objects. QObject is the heart of the Qt Object Model.The central feature in this model is a very powerful mechanism for seamless object communication called signals and slots.
As the documentation states, this function will recursively search the given object for signals matching the format of:
If you’re using Qt Designer and MOC’ing, this fuction gets called automatically in your ui_<mainwindow>.h
file inside of setupUi()
. This means that you don’t have to manually connect the objects in your .ui
files. I didn’t know this! You can simply do something like:
And that’s it! You don’t have to define the signals/slots in Designer, you don’t have to manually connect them (as I had been doing). Nothing! It just works!
I had never seen this mentioned in any tutorial or even code examples. I only stumbled upon it when looking at another project for something completely unrelated. But this is a great time saver!
Manage connections between VTK events and Qt slots. More...
#include <vtkEventQtSlotConnect.h>
Public Types | |
typedef vtkObject | Superclass |
Public Member Functions | |
virtual vtkTypeBool | IsA (const char *type) |
Return 1 if this class is the same type of (or a subclass of) the named class. More... | |
vtkEventQtSlotConnect * | NewInstance () const |
void | PrintSelf (ostream &os, vtkIndent indent) override |
Print the current connections between VTK and Qt. More... | |
virtual void | Connect (vtkObject *vtk_obj, unsigned long event, const QObject *qt_obj, const char *slot, void *client_data=nullptr, float priority=0.0, Qt::ConnectionType type=Qt::AutoConnection) |
Connect a vtk object's event with a Qt object's slot. More... | |
virtual void | Disconnect (vtkObject *vtk_obj=nullptr, unsigned long event=vtkCommand::NoEvent, const QObject *qt_obj=nullptr, const char *slot=nullptr, void *client_data=nullptr) |
Disconnect a vtk object from a qt object. More... | |
virtual int | GetNumberOfConnections () const |
Allow to query vtkEventQtSlotConnect to know if some Connect() have been setup and how many. More... | |
Public Member Functions inherited from vtkObject | |
vtkBaseTypeMacro (vtkObject, vtkObjectBase) | |
virtual void | DebugOn () |
Turn debugging output on. More... | |
virtual void | DebugOff () |
Turn debugging output off. More... | |
bool | GetDebug () |
Get the value of the debug flag. More... | |
void | SetDebug (bool debugFlag) |
Set the value of the debug flag. More... | |
virtual void | Modified () |
Update the modification time for this object. More... | |
virtual vtkMTimeType | GetMTime () |
Return this object's modified time. More... | |
unsigned long | AddObserver (unsigned long event, vtkCommand *, float priority=0.0f) |
Allow people to add/remove/invoke observers (callbacks) to any VTK object. More... | |
unsigned long | AddObserver (const char *event, vtkCommand *, float priority=0.0f) |
vtkCommand * | GetCommand (unsigned long tag) |
void | RemoveObserver (vtkCommand *) |
void | RemoveObservers (unsigned long event, vtkCommand *) |
void | RemoveObservers (const char *event, vtkCommand *) |
vtkTypeBool | HasObserver (unsigned long event, vtkCommand *) |
vtkTypeBool | HasObserver (const char *event, vtkCommand *) |
void | RemoveObserver (unsigned long tag) |
void | RemoveObservers (unsigned long event) |
void | RemoveObservers (const char *event) |
void | RemoveAllObservers () |
vtkTypeBool | HasObserver (unsigned long event) |
vtkTypeBool | HasObserver (const char *event) |
template<class U , class T > | |
unsigned long | AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f) |
Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More... | |
template<class U , class T > | |
unsigned long | AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f) |
template<class U , class T > | |
unsigned long | AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f) |
Allow user to set the AbortFlagOn() with the return value of the callback method. More... | |
int | InvokeEvent (unsigned long event, void *callData) |
This method invokes an event and return whether the event was aborted or not. More... | |
int | InvokeEvent (const char *event, void *callData) |
int | InvokeEvent (unsigned long event) |
int | InvokeEvent (const char *event) |
Public Member Functions inherited from vtkObjectBase | |
const char * | GetClassName () const |
Return the class name as a string. More... | |
virtual vtkIdType | GetNumberOfGenerationsFromBase (const char *name) |
Given the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More... | |
virtual void | Delete () |
Delete a VTK object. More... | |
virtual void | FastDelete () |
Delete a reference to this object. More... | |
void | InitializeObjectBase () |
void | Print (ostream &os) |
Print an object to an ostream. More... | |
virtual void | PrintHeader (ostream &os, vtkIndent indent) |
virtual void | PrintTrailer (ostream &os, vtkIndent indent) |
virtual void | Register (vtkObjectBase *o) |
Increase the reference count (mark as used by another object). More... | |
virtual void | UnRegister (vtkObjectBase *o) |
Decrease the reference count (release by another object). More... | |
int | GetReferenceCount () |
Return the current reference count of this object. More... | |
void | SetReferenceCount (int) |
Sets the reference count. More... | |
bool | GetIsInMemkind () const |
A local state flag that remembers whether this object lives in the normal or extended memory space. More... |
Static Public Member Functions | |
static vtkEventQtSlotConnect * | New () |
static vtkTypeBool | IsTypeOf (const char *type) |
static vtkEventQtSlotConnect * | SafeDownCast (vtkObjectBase *o) |
Static Public Member Functions inherited from vtkObject | |
static vtkObject * | New () |
Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More... | |
static void | BreakOnError () |
This method is called when vtkErrorMacro executes. More... | |
static void | SetGlobalWarningDisplay (int val) |
This is a global flag that controls whether any debug, warning or error messages are displayed. More... | |
static void | GlobalWarningDisplayOn () |
static void | GlobalWarningDisplayOff () |
static int | GetGlobalWarningDisplay () |
Static Public Member Functions inherited from vtkObjectBase | |
static vtkTypeBool | IsTypeOf (const char *name) |
Return 1 if this class type is the same type of (or a subclass of) the named class. More... | |
static vtkIdType | GetNumberOfGenerationsFromBaseType (const char *name) |
Given a the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More... | |
static vtkObjectBase * | New () |
Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More... | |
static void | SetMemkindDirectory (const char *directoryname) |
The name of a directory, ideally mounted -o dax, to memory map an extended memory space within. More... | |
static bool | GetUsingMemkind () |
A global state flag that controls whether vtkObjects are constructed in the usual way (the default) or within the extended memory space. More... |
Protected Member Functions | |
virtual vtkObjectBase * | NewInstanceInternal () const |
void | RemoveConnection (vtkQtConnection *) |
vtkEventQtSlotConnect () | |
~vtkEventQtSlotConnect () override | |
Protected Member Functions inherited from vtkObject | |
vtkObject () | |
~vtkObject () override | |
void | RegisterInternal (vtkObjectBase *, vtkTypeBool check) override |
void | UnRegisterInternal (vtkObjectBase *, vtkTypeBool check) override |
void | InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr) |
These methods allow a command to exclusively grab all events. More... | |
void | InternalReleaseFocus () |
Protected Member Functions inherited from vtkObjectBase | |
vtkObjectBase () | |
virtual | ~vtkObjectBase () |
virtual void | ReportReferences (vtkGarbageCollector *) |
vtkObjectBase (const vtkObjectBase &) | |
void | operator= (const vtkObjectBase &) |
Protected Attributes | |
vtkQtConnections * | Connections |
Protected Attributes inherited from vtkObject | |
bool | Debug |
vtkTimeStamp | MTime |
vtkSubjectHelper * | SubjectHelper |
Protected Attributes inherited from vtkObjectBase | |
std::atomic< int32_t > | ReferenceCount |
vtkWeakPointerBase ** | WeakPointers |
Friends | |
class | vtkQtConnection |
Additional Inherited Members | |
Static Protected Member Functions inherited from vtkObjectBase | |
static vtkMallocingFunction | GetCurrentMallocFunction () |
static vtkReallocingFunction | GetCurrentReallocFunction () |
static vtkFreeingFunction | GetCurrentFreeFunction () |
static vtkFreeingFunction | GetAlternateFreeFunction () |
Detailed Description
Manage connections between VTK events and Qt slots.
vtkEventQtSlotConnect provides a way to manage connections between VTK events and Qt slots. Qt slots to connect with must have one of the following signatures:
- MySlot()
- MySlot(vtkObject* caller)
- MySlot(vtkObject* caller, unsigned long vtk_event)
- MySlot(vtkObject* caller, unsigned long vtk_event, void* client_data)
- MySlot(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data)
- MySlot(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data, vtkCommand*)
Definition at line 57 of file vtkEventQtSlotConnect.h.
Member Typedef Documentation
◆ Superclass
typedef vtkObjectvtkEventQtSlotConnect::Superclass |
Definition at line 61 of file vtkEventQtSlotConnect.h.
Constructor & Destructor Documentation
◆ vtkEventQtSlotConnect()
| protected |
◆ ~vtkEventQtSlotConnect()
| overrideprotected |
Member Function Documentation
◆ New()
| static |
◆ IsTypeOf()
| static |
◆ IsA()
| virtual |
Return 1 if this class is the same type of (or a subclass of) the named class.
Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.
Reimplemented from vtkObjectBase.
Qt Slot Derived Class C
◆ SafeDownCast()
| static |
◆ NewInstanceInternal()
| protectedvirtual |
◆ NewInstance()
vtkEventQtSlotConnect* vtkEventQtSlotConnect::NewInstance | ( | ) | const |
Qt No Such Slot In Derived Class
◆ PrintSelf()
| overridevirtual |
Print the current connections between VTK and Qt.
Reimplemented from vtkObject.
◆ Connect()
| virtual |
Connect a vtk object's event with a Qt object's slot.
Multiple connections which are identical are treated as separate connections.
◆ Disconnect()
Qt Slot Derived Class Example
| virtual |
Disconnect a vtk object from a qt object.
Passing no arguments will disconnect all slots maintained by this object. Passing in only a vtk object will disconnect all slots from it. Passing only a vtk object and event, will disconnect all slots matching the vtk object and event. Passing all information in will match all information.
◆ GetNumberOfConnections()
| virtual |
Allow to query vtkEventQtSlotConnect to know if some Connect() have been setup and how many.
◆ RemoveConnection()
| protected |
Friends And Related Function Documentation
◆ vtkQtConnection
Definition at line 95 of file vtkEventQtSlotConnect.h.
Member Data Documentation
◆ Connections
| protected |
Definition at line 94 of file vtkEventQtSlotConnect.h.
The documentation for this class was generated from the following file:- GUISupport/Qt/vtkEventQtSlotConnect.h