På den här sidan

Core::ActionBuilder Class

class Core::ActionBuilder

Klassen ActionBuilder är en hjälpklass för att konfigurer Core::Command. Mer...

Header: #include <coreplugin/actionmanager/actionmanager.h>

Offentliga funktioner

ActionBuilder(QObject *contextActionParent, const Utils::Id actionId)
~ActionBuilder()
Core::ActionBuilder &adopt(Utils::Action *action)
Core::ActionBuilder &setIconText(const QString &iconText)
Core::ActionBuilder &setText(const QString &text)

Detaljerad beskrivning

En action builder specificerar egenskaper för en Core::Command och en kontextåtgärd och använder ActionManager::registerAction() i sin destruktor för att faktiskt registrera åtgärden för en inställd Core::Context för Command.

Dokumentation för medlemsfunktioner

ActionBuilder::ActionBuilder(QObject *contextActionParent, const Utils::Id actionId)

Skapar en åtgärdsgenerator för en åtgärd med ID:t actionId.

contextActionParent används för att tillhandahålla en QObject -överordnad för det internt skapade QAction -objektet för att styra dess livslängd.

Detta är vanligtvis pekaren this för den entitet som använder ActionBuilder.

[noexcept] ActionBuilder::~ActionBuilder()

Registrerar den skapade åtgärden med de angivna egenskaperna.

Se även ActionManager::registerAction().

Core::ActionBuilder &ActionBuilder::adopt(Utils::Action *action)

Använder den angivna action som contextAction för denna builder. action får inte vara nullptr, och adopt() måste anropas innan några faktiska egenskaper ställs in, såsom setText() eller setIcon().

Vanligtvis bör du föredra att skicka en contextActionParent till ActionBuilder -konstruktorn och binda en QAction till den automatiskt skapade kontextåtgärden med bindContextAction().

Denna metod kan ibland vara användbar om den som anropar själv hanterar åtgärdens livslängd, och det till exempel inte finns någon QObject som kan fungera som överordnad för en automatiskt skapad kontextåtgärd.

Core::ActionBuilder &ActionBuilder::setIconText(const QString &iconText)

Ställer in egenskapen iconText för den åtgärd som håller på att skapas till iconText.

Se även QAction::setIconText().

Core::ActionBuilder &ActionBuilder::setText(const QString &text)

Ställer in egenskapen text för den åtgärd som håller på att skapas till text.

Se även QAction::setText().

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU 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.