UiSignalBridge Class
The UI Signal Bridge enables cross-form signal forwarding in local UI More...
Header: | #include <UiSignalBridge> |
Properties
- targetObjectName : QString
Public Functions
UiSignalBridge(QWidget *parent) | |
void | setTargetObjectName(const QString &v) |
QString | targetObjectName() const |
Public Slots
void | forward() |
void | forwardBool(bool v) |
void | forwardDouble(double v) |
void | forwardInt(int v) |
void | forwardString(const QString &s) |
void | forwardVariant(const QVariant &x) |
Signals
void | forwardedBool(bool) |
void | forwardedDouble(double) |
void | forwardedInt(int) |
void | forwardedString(const QString &) |
void | forwardedVariant(const QVariant &) |
void | triggered() |
Protected Functions
void | emitBool(bool v) |
void | emitDouble(double v) |
void | emitInt(int v) |
void | emitString(const QString &s) |
void | emitVariant(const QVariant &x) |
void | emitVoid() |
Detailed Description
The UI Signal Bridge enables cross-form signal forwarding in local UI
Forwarding works by placing a UI Signal Bridge in the form that emits the signals to forward, and another in the form that has slots to receive them. The bridge in the sending form must configure its targetObjectName with the object name of the receiving bridge. Finally, connect the signal-and-slots to the bridge elements in both the sending and receiving forms, as explained in the example further down.
Use this widget for local, UI-only interactions between forms. For example, a dialog submenu that changes the current page of a Stacked Widget in the main window.
Connecting widgets using signal-and-slots is preferred over control system routing when the interaction should remain local to the UI without generating cross-application traffic.
When targetObjectName is empty or not found, the selector emits its forwarded signals locally. This can be useful for converting numeric values, since the widget re-emits them as bool
, int
, and double
, while other types such as string
and variant
are forwarded unchanged. For conversions, bool
is true for values >= 1.0, and conversion from double
to int
uses round-to-nearest.
Example: Dialog Menu to Main Window StackedWidget
The following example forwards checked(int)
signals from multiple buttons in a dialog to control the current page of a stacked widget in the main window. This mirrors the Submenu example in the Open Bridge template (available from the file wizard).
Receiver (MainWindow.ui)
- Add a non-visual UiSignalBridge and set objectName to
MainStackBridge
. - Connect
MainStackBridge.forwardedInt(int)
->stackedWidget.setCurrentIndex(int)
.
Sender (Dialog.ui)
- Add a non-visual UiSignalBridge and set targetObjectName to
MainStackBridge
. - Add menu buttons and make sure their
valueToEmit
property is set similar to the page you would like them to trigger. When a button is clicked it will emit this value using itschecked(int)
signal. - Connect
button.checked(int)
->UiSignalBridge.forwardInt(int)
for each button.
Property Documentation
targetObjectName : QString
This property holds which UiSignalBridge instance will receive and emit the forwarded signal.
Set this to the object name of a UiSignalBridge in another form that should handle the signal. When set, forwarded values will be routed to that target instance, which will then emit the corresponding forwarded signal. If left empty, the current instance emits the value locally.
Access functions:
QString | targetObjectName() const |
void | setTargetObjectName(const QString &v) |
Member Function Documentation
UiSignalBridge::UiSignalBridge(QWidget *parent)
Default constructs an instance of UiSignalBridge.
[protected]
void UiSignalBridge::emitBool(bool v)
[protected]
void UiSignalBridge::emitDouble(double v)
[protected]
void UiSignalBridge::emitInt(int v)
[protected]
void UiSignalBridge::emitString(const QString &s)
[protected]
void UiSignalBridge::emitVariant(const QVariant &x)
[protected]
void UiSignalBridge::emitVoid()
[slot]
void UiSignalBridge::forward()
[slot]
void UiSignalBridge::forwardBool(bool v)
[slot]
void UiSignalBridge::forwardDouble(double v)
[slot]
void UiSignalBridge::forwardInt(int v)
[slot]
void UiSignalBridge::forwardString(const QString &s)
[slot]
void UiSignalBridge::forwardVariant(const QVariant &x)
[signal]
void UiSignalBridge::forwardedBool(bool)
[signal]
void UiSignalBridge::forwardedDouble(double)
[signal]
void UiSignalBridge::forwardedInt(int)
[signal]
void UiSignalBridge::forwardedString(const QString &)
[signal]
void UiSignalBridge::forwardedVariant(const QVariant &)
[signal]
void UiSignalBridge::triggered()
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.