<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # QUndoCommand Class Reference ## [[QtGui](index.htm) module] 該QUndoCommand類是所有的命令存儲在基類[QUndoStack](qundostack.html)。[More...](#details) ### Methods * `__init__ (self, QUndoCommand?parent?=?None)` * `__init__ (self, QString?text, QUndoCommand?parent?=?None)` * `QString actionText (self)` * `QUndoCommand child (self, int?index)` * `int childCount (self)` * `int id (self)` * `bool mergeWith (self, QUndoCommand?other)` * `redo (self)` * `setText (self, QString?text)` * `QString text (self)` * `undo (self)` * * * ## Detailed Description 該QUndoCommand類是所有的命令存儲在基類[QUndoStack](qundostack.html)。 對于Qt的復原框架的概述,請參閱[overview document](index.htm)。 一個QUndoCommand代表文檔中的單個編輯操作,例如,插入或刪除一個文本編輯器文本塊。 QUndoCommand可以申請更改的文件與[redo](qundocommand.html#redo)()和撤銷與變更[undo](qundocommand.html#undo)( ) 。在實現這些功能必須在派生類中提供。 ``` class AppendText : public QUndoCommand { public: AppendText([QString](qstring.html) *doc, const [QString](qstring.html) &text) : m_document(doc), m_text(text) { setText("append text"); } virtual void undo() { m_document->chop(m_text.length()); } virtual void redo() { m_document->append(m_text); } private: [QString](qstring.html) *m_document; [QString](qstring.html) m_text; }; ``` 一個QUndoCommand都有一個關聯的[text](qundocommand.html#text)( ) 。這是一個短字符串描述該命令功能。它是用來更新堆棧的撤消的文本屬性和重復動作,見[QUndoStack.createUndoAction](qundostack.html#createUndoAction)()和[QUndoStack.createRedoAction](qundostack.html#createRedoAction)( ) 。 QUndoCommand對象由堆棧他們被壓入資。[QUndoStack](qundostack.html)刪除的命令,如果它已被撤消和一個新的命令被推動。例如: ``` MyCommand *command1 = new MyCommand(); stack->push(command1); MyCommand *command2 = new MyCommand(); stack->push(command2); stack->undo(); MyCommand *command3 = new MyCommand(); stack->push(command3); // command2 gets deleted ``` 實際上,當命令被按下時,它成為堆棧上的最頂層的命令。 為了支持命令壓縮, QUndoCommand有[id](qundocommand.html#id)( )和虛擬功能[mergeWith](qundocommand.html#mergeWith)( ) 。這些功能所使用的[QUndoStack.push](qundostack.html#push)( ) 。 為了支持宏命令,一個QUndoCommand對象可以有任意數量的子命令。撤消或重做父的命令會讓孩子命令撤消或重做。命令可以在構造函數中顯式地指定給父母。在這種情況下,該命令將被父所擁有。 在這種情況下,父通常是一個空命令,因為它不提供它自己的實現的[undo](qundocommand.html#undo)()和[redo](qundocommand.html#redo)( ) 。相反,它使用這些功能的基本實現,它只是簡單的調用[undo](qundocommand.html#undo)()或[redo](qundocommand.html#redo)( )在它的所有子項。家長應,然而,有一個有意義的[text](qundocommand.html#text)( ) 。 ``` QUndoCommand *insertRed = new QUndoCommand(); // an empty command insertRed->setText("insert red text"); new InsertText(document, idx, text, insertRed); // becomes child of insertRed new SetColor(document, idx, text.length(), [Qt](qt.html).red, insertRed); stack.push(insertRed); ``` 另一種方式來創建宏是使用便利的功能[QUndoStack.beginMacro](qundostack.html#beginMacro)()和[QUndoStack.endMacro](qundostack.html#endMacro)( ) 。 * * * ## Method Documentation ``` QUndoCommand.__init__ (self, QUndoCommand?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 構造一個[QUndoCommand](qundocommand.html)與父對象_parent_。 If _parent_不為0 ,則該命令被添加到父節點的子列表。父命令則擁有這個命令將在其析構函數刪除它。 **See also** [~QUndoCommand](qundocommand.html#dtor.QUndoCommand)( ) 。 ``` QUndoCommand.__init__ (self, QString?text, QUndoCommand?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 構造一個[QUndoCommand](qundocommand.html)與給定對象_parent_和_text_。 If _parent_不為0 ,則該命令被添加到父節點的子列表。父命令則擁有這個命令將在其析構函數刪除它。 **See also** [~QUndoCommand](qundocommand.html#dtor.QUndoCommand)( ) 。 ``` QString QUndoCommand.actionText (self) ``` 返回描述了這個命令做了簡短的文本字符串,例如, “插入文字” 。 該文本時使用的堆棧的撤消的文本屬性和重復動作被更新。 此功能被引入Qt的4.8 。 **See also** [text](qundocommand.html#text)( )[setText](qundocommand.html#setText)( )[QUndoStack.createUndoAction](qundostack.html#createUndoAction)()和[QUndoStack.createRedoAction](qundostack.html#createRedoAction)( ) 。 ``` QUndoCommand QUndoCommand.child (self, int?index) ``` [ 在返回的子命令_index_。 此功能被引入Qt的4.4 。 ](qundocommand.html) [**See also**](qundocommand.html) [childCount](qundocommand.html#childCount)()和[QUndoStack.command](qundostack.html#command)( ) 。 ``` int QUndoCommand.childCount (self) ``` 返回此命令子命令的數量。 此功能被引入Qt的4.4 。 **See also** [child](qundocommand.html#child)( ) 。 ``` int QUndoCommand.id (self) ``` 返回此命令的ID 。 命令ID用來在命令壓縮。它必須是一個整數獨此命令的類,或者-1如果命令不支持壓縮。 如果命令支持壓縮這個函數必須在派生類中重寫以返回正確的ID 。基實現返回-1 。 [QUndoStack.push](qundostack.html#push)()將只嘗試合并兩個命令,如果它們具有相同的ID,并且該ID不是-1。 **See also** [mergeWith](qundocommand.html#mergeWith)()和[QUndoStack.push](qundostack.html#push)( ) 。 ``` bool QUndoCommand.mergeWith (self, QUndoCommand?other) ``` 嘗試與合并這個命令_command_。成功時返回TRUE ,否則返回False 。 如果這個函數返回True,則調用此命令的[redo](qundocommand.html#redo)( )必須具有相同的效果,既重做這個命令和_command_。同樣,調用此命令的[undo](qundocommand.html#undo)( )必須具有相同的效果撤消_command_與此命令。 [QUndoStack](qundostack.html)只會嘗試合并兩個命令,如果他們有相同的id ,而id是不是-1 。 默認實現返回False 。 ``` bool AppendText.mergeWith(const [QUndoCommand](qundocommand.html) *other) { if (other->id() != id()) // make sure other is also an AppendText command return false; m_text += static_cast<const AppendText*>(other)->m_text; return true; } ``` **See also** [id](qundocommand.html#id)()和[QUndoStack.push](qundostack.html#push)( ) 。 ``` QUndoCommand.redo (self) ``` 適用變更的文件。這個函數必須在派生類中實現。調用[QUndoStack.push](qundostack.html#push)( )[QUndoStack.undo](qundostack.html#undo)()或[QUndoStack.redo](qundostack.html#redo)從這個函數( )導致未定義beahavior 。 默認實現調用重做( )對所有的子命令。 **See also** [undo](qundocommand.html#undo)( ) 。 ``` QUndoCommand.setText (self, QString?text) ``` 設置為命令的文本_text_規定。 指定文本應描述了這個命令的作用很短的用戶可讀的字符串。 如果你需要有兩個不同的字符串[text](qundocommand.html#text)()和[actionText](qundocommand.html#actionText)( ) ,將它們分開為“\ n ” ,并傳遞到這個函數。即使你在開發過程中不使用此功能的英文字符串,你仍然可以讓翻譯使用兩個不同的字符串,以匹配特定語言的需求。所描述的特征和??功能[actionText](qundocommand.html#actionText)( )是因為Qt的4.8可用。 **See also** [text](qundocommand.html#text)( )[actionText](qundocommand.html#actionText)( )[QUndoStack.createUndoAction](qundostack.html#createUndoAction)()和[QUndoStack.createRedoAction](qundostack.html#createRedoAction)( ) 。 ``` QString QUndoCommand.text (self) ``` 返回描述了這個命令做了簡短的文本字符串,例如, “插入文字” 。 該文本是用于項目的名稱[QUndoView](qundoview.html)。 **See also** [actionText](qundocommand.html#actionText)( )[setText](qundocommand.html#setText)( )[QUndoStack.createUndoAction](qundostack.html#createUndoAction)()和[QUndoStack.createRedoAction](qundostack.html#createRedoAction)( ) 。 ``` QUndoCommand.undo (self) ``` 恢復一個變化到文檔中。撤消()被調用后,文件的狀態應該是和以前一樣[redo](qundocommand.html#redo)( )被調用。這個函數必須在派生類中實現。調用[QUndoStack.push](qundostack.html#push)( )[QUndoStack.undo](qundostack.html#undo)()或[QUndoStack.redo](qundostack.html#redo)從這個函數( )導致未定義beahavior 。 默認實現調用撤消( )上的所有子命令的順序相反。 **See also** [redo](qundocommand.html#redo)( ) 。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看