https://wiki.qt.io/index.php?title=Extending_QAction_by_emitting_additional_Signals/de&feed=atom&action=history
Extending QAction by emitting additional Signals/de - Revision history
2024-03-29T07:05:54Z
Revision history for this page on the wiki
MediaWiki 1.39.4
https://wiki.qt.io/index.php?title=Extending_QAction_by_emitting_additional_Signals/de&diff=13082&oldid=prev
Simow: /* Quelltext */
2015-03-11T23:37:42Z
<p><span dir="auto"><span class="autocomment">Quelltext</span></span></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 23:37, 11 March 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l57">Line 57:</td>
<td colspan="2" class="diff-lineno">Line 57:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>#endif // CHECKABLEACTION_H</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>#endif // CHECKABLEACTION_H</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></code></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></code></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">Implementierung:</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><code></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><code></div></td></tr>
</table>
Simow
https://wiki.qt.io/index.php?title=Extending_QAction_by_emitting_additional_Signals/de&diff=13081&oldid=prev
Simow: Localisation
2015-03-11T23:37:16Z
<p>Localisation</p>
<a href="//wiki.qt.io/index.php?title=Extending_QAction_by_emitting_additional_Signals/de&diff=13081&oldid=13079">Show changes</a>
Simow
https://wiki.qt.io/index.php?title=Extending_QAction_by_emitting_additional_Signals/de&diff=13079&oldid=prev
Simow: Simow moved page ActionEmittingCheckedUncheckedSignals German to Extending QAction by emitting additional Signals/de: Localisation
2015-03-11T23:31:04Z
<p>Simow moved page <a href="/ActionEmittingCheckedUncheckedSignals_German" class="mw-redirect" title="ActionEmittingCheckedUncheckedSignals German">ActionEmittingCheckedUncheckedSignals German</a> to <a href="/Extending_QAction_by_emitting_additional_Signals/de" title="Extending QAction by emitting additional Signals/de">Extending QAction by emitting additional Signals/de</a>: Localisation</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 23:31, 11 March 2015</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Simow
https://wiki.qt.io/index.php?title=Extending_QAction_by_emitting_additional_Signals/de&diff=12236&oldid=prev
AutoSpider: Convert ExpressionEngine section headers
2015-03-05T15:37:53Z
<p>Convert ExpressionEngine section headers</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 15:37, 5 March 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l13">Line 13:</td>
<td colspan="2" class="diff-lineno">Line 13:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Es oft praktischer, wenn man 2 getrennte Signale hätte: Eins für "der Zustand ist jetzt ''checked''" und eins für "er ist jetzt nicht ''checked''". Weil QAction solche Signale nicht hat, bauen wir uns hier eine von QAction abgeleitete Klasse, die QAction um eben diese Signale erweitert.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Es oft praktischer, wenn man 2 getrennte Signale hätte: Eins für "der Zustand ist jetzt ''checked''" und eins für "er ist jetzt nicht ''checked''". Weil QAction solche Signale nicht hat, bauen wir uns hier eine von QAction abgeleitete Klasse, die QAction um eben diese Signale erweitert.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">h2. </del>Quelltext</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">== </ins>Quelltext <ins style="font-weight: bold; text-decoration: none;">==</ins></div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td colspan="2" class="diff-side-added"></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Der Quelltext ist wirklich einfach. Dies ist die Header-Datei:</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Der Quelltext ist wirklich einfach. Dies ist die Header-Datei:</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l104">Line 104:</td>
<td colspan="2" class="diff-lineno">Line 103:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></code></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></code></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">h2. </del>Beispiel zur Verwendung</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">== </ins>Beispiel zur Verwendung <ins style="font-weight: bold; text-decoration: none;">==</ins></div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td colspan="2" class="diff-side-added"></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>The action can be used in the way a QAction is, for instance:</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>The action can be used in the way a QAction is, for instance:</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Die neue Klasse wird genauso benutzt, wie eine QAction, bloß dass uns jetzt die 2 neuen Signale <code>actionChecked()</code> und <code>actionUnchecked()</code> zur Verfügung stehen.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Die neue Klasse wird genauso benutzt, wie eine QAction, bloß dass uns jetzt die 2 neuen Signale <code>actionChecked()</code> und <code>actionUnchecked()</code> zur Verfügung stehen.</div></td></tr>
</table>
AutoSpider
https://wiki.qt.io/index.php?title=Extending_QAction_by_emitting_additional_Signals/de&diff=8661&oldid=prev
Maintenance script at 07:16, 2 March 2015
2015-03-02T07:16:05Z
<p></p>
<p><b>New page</b></p><div>[[Category:HowTo]]<br />
[[Category:snippets]]<br />
[[Category:German]]<br />
<br />
'''Deutsch''' | [[ActionEmittingCheckedUncheckedSignals|English]]<br />
<br />
= Wie man eine Klasse von QAction ableitet, sodass sie Checked/Unchecked-Signale sendet =<br />
<br />
QAction kann so konfiguriert werden, dass es ''checkable'' ist. Dies bedeutet, es kann einen binären Zustand, nämlich ''angewählt'' (''checked'') und ''nicht_angewählt'' annehmen. Dies wird bspw. bei einem Pushbutton angezeigt, der runtergedrückt bleibt, nachdem man ihn einmal geklickt hat und erst wieder in den Ausgangszustand zurückkehrt, nachdem man ihn noch ein weiteres mal angeklickt hat.<br />
<br />
Das Problem mit QAction ist, dass es nur ein Signal sendet, wenn sich sein ''checked''-Zustand geändert hat und in diesem Signal mit einem boolschen Attribut mitteilt, ob der Zustand nun ''checked'' ist oder nicht. Das bedeutet, wenn man eine Slot-Methode schreibt, die auf dieses Signal reagiert, muss man in diesem Slot erst gucken, wie der Zustand der QAction jetzt ist und dann kann man erst, basierend auf dieser Fallentscheidung, die gewünschte Funktion ausführen.<br />
<br />
Es oft praktischer, wenn man 2 getrennte Signale hätte: Eins für "der Zustand ist jetzt ''checked''" und eins für "er ist jetzt nicht ''checked''". Weil QAction solche Signale nicht hat, bauen wir uns hier eine von QAction abgeleitete Klasse, die QAction um eben diese Signale erweitert.<br />
<br />
h2. Quelltext<br />
<br />
Der Quelltext ist wirklich einfach. Dies ist die Header-Datei:<br />
<br />
<code>#ifndef CHECKABLEACTION_H<br />
#define CHECKABLEACTION_H<br />
<br />
#include <QAction><br />
#include <QDebug><br />
<br />
/*!<br />
* This class represents an action that will emit<br />
* distinct signals depending on the check of the<br />
* action itself.<br />
*/<br />
class CheckableAction : public QAction<br />
{<br />
Q_OBJECT<br />
public:<br />
explicit CheckableAction(QObject '''parent = 0);<br />
<br />
signals:<br />
<br />
/*!<br />
* This signal is emitted each time the action is<br />
* checked.<br />
*/<br />
void actionChecked();<br />
<br />
/*!<br />
* This signal is emitted each time the action is<br />
* unchecked.<br />
*/<br />
void actionUnchecked();<br />
<br />
<br />
<br />
public slots:<br />
<br />
<br />
private slots:<br />
<br />
/*!<br />
* This slot is used to forward (i.e., emit) a triggered<br />
* event depending on the status of the action (i.e., if it<br />
* has been checked or not).<br />
* checked true if the action has been checked, false<br />
* otherwise<br />
*/<br />
void slotForwardCheckSignal( bool checked );<br />
<br />
};<br />
<br />
#endif // CHECKABLEACTION_H<br />
</code><br />
<br />
<br />
Und hier folgt nun die Implementierung der Klasse:<br />
<br />
<code>#include "checkableaction.h"<br />
<br />
CheckableAction::CheckableAction(QObject '''parent) :<br />
QAction(parent)<br />
{<br />
// auto connect the triggered event to the slot for<br />
// forwarding the check status<br />
connect( this,<br />
SIGNAL (triggered(bool)),<br />
this,<br />
SLOT (slotForwardCheckSignal(bool)) );<br />
}<br />
<br />
void CheckableAction::slotForwardCheckSignal(bool checked)<br />
{<br />
qDebug() << "Action checked status " << checked;<br />
// check the status of the action<br />
if( ! isCheckable() )<br />
// the action cannot be checked, simply emit<br />
// a triggered event<br />
triggered();<br />
else<br />
if( isChecked() )<br />
// the action is checked<br />
emit actionChecked();<br />
else<br />
// the action is unchecked<br />
emit actionUnchecked();<br />
<br />
}<br />
</code><br />
<br />
h2. Beispiel zur Verwendung<br />
<br />
The action can be used in the way a QAction is, for instance:<br />
Die neue Klasse wird genauso benutzt, wie eine QAction, bloß dass uns jetzt die 2 neuen Signale <code>actionChecked()</code> und <code>actionUnchecked()</code> zur Verfügung stehen.<br />
<br />
<code><br />
CheckableAction''' myAction = new CheckableAction( this );<br />
myAction->setText( tr("Action TEXT") );<br />
myAction->setIcon( QIcon(":/actions/img/myaction.png") );<br />
myAction->setStatusTip( tr("Check/Uncheck the action") );<br />
myAction->setCheckable( true );<br />
connect( myAction,<br />
SIGNAL (actionChecked()),<br />
this,<br />
SLOT( slotActionUncheked()) );<br />
connect( myAction,<br />
SIGNAL (actionUnchecked()),<br />
this,<br />
SLOT (slotActionCheked()) );<br />
<br />
</code></div>
Maintenance script