<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # QAbstractItemDelegate Class Reference ## [[QtGui](index.htm) module] 該QAbstractItemDelegate類用于從模型顯示和編輯數據項。[More...](#details) 繼承[QObject](qobject.html)。 通過繼承[QItemDelegate](qitemdelegate.html)和[QStyledItemDelegate](qstyleditemdelegate.html)。 ### Types * `enum EndEditHint { NoHint, EditNextItem, EditPreviousItem, SubmitModelCache, RevertModelCache }` ### Methods * `__init__ (self, QObject?parent?=?None)` * `QWidget createEditor (self, QWidget?parent, QStyleOptionViewItem?option, QModelIndex?index)` * `bool editorEvent (self, QEvent?event, QAbstractItemModel?model, QStyleOptionViewItem?option, QModelIndex?index)` * `bool helpEvent (self, QHelpEvent?event, QAbstractItemView?view, QStyleOptionViewItem?option, QModelIndex?index)` * `paint (self, QPainter?painter, QStyleOptionViewItem?option, QModelIndex?index)` * `setEditorData (self, QWidget?editor, QModelIndex?index)` * `setModelData (self, QWidget?editor, QAbstractItemModel?model, QModelIndex?index)` * `QSize sizeHint (self, QStyleOptionViewItem?option, QModelIndex?index)` * `updateEditorGeometry (self, QWidget?editor, QStyleOptionViewItem?option, QModelIndex?index)` ### Static Methods * `QString elidedText (QFontMetrics?fontMetrics, int?width, Qt.TextElideMode?mode, QString?text)` ### Qt Signals * `void closeEditor (QWidget *,QAbstractItemDelegate::EndEditHint = QAbstractItemDelegate.NoHint)` * `void commitData (QWidget *)` * `void sizeHintChanged (const QModelIndex&)` * * * ## Detailed Description 該QAbstractItemDelegate類用于從模型顯示和編輯數據項。 一個QAbstractItemDelegate提供了在模型/視圖結構代表的接口和通用的功能。代表們顯示在視圖中的個別項目,并處理模型數據的編輯。 該QAbstractItemDelegate類是一個[Model/View Classes](index.htm)并且是Qt的一部分[model/view framework](index.htm)。 呈現在一個自定義的方法的項目,則必須實現[paint](qabstractitemdelegate.html#paint)()和[sizeHint](qabstractitemdelegate.html#sizeHint)( ) 。該[QItemDelegate](qitemdelegate.html)類提供默認實現這些功能,如果你不需要自定義的渲染,繼承這個類來代替。 我們給畫中的項目一個進度條的例子,在我們的例子中的一個包管理程序。 ![](https://img.kancloud.cn/fe/02/fe02d78e7ac913dc8a8082acd25cd78b_303x151.png) 我們創造的`WidgetDelegate`類,它繼承自[QStyledItemDelegate](qstyleditemdelegate.html)。我們在繪圖[paint](qabstractitemdelegate.html#paint)( )函數: ``` void WidgetDelegate.paint([QPainter](qpainter.html) *painter, const [QStyleOptionViewItem](qstyleoptionviewitem.html) &option, const [QModelIndex](qmodelindex.html) &index) const { if (index.column() == 1) { int progress = index.data().toInt(); [QStyleOptionProgressBar](qstyleoptionprogressbar.html) progressBarOption; progressBarOption.rect = option.rect; progressBarOption.minimum = 0; progressBarOption.maximum = 100; progressBarOption.progress = progress; progressBarOption.text = [QString](qstring.html).number(progress) + "%"; progressBarOption.textVisible = true; [QApplication](qapplication.html).style()->drawControl([QStyle](qstyle.html).CE_ProgressBar, &progressBarOption, painter); } else [QStyledItemDelegate](qstyleditemdelegate.html).paint(painter, option, index); ``` 請注意,我們使用了[QStyleOptionProgressBar](qstyleoptionprogressbar.html)并初始化它的成員。然后,我們可以使用當前[QStyle](qstyle.html)繪制它。 提供自定義編輯,有可以使用的兩種方法。第一種方法是創建一個編輯器窗口小部件,并直接對項目的頂部顯示。要做到這一點,你必須重新實現[createEditor](qabstractitemdelegate.html#createEditor)( )提供一個編輯器部件,[setEditorData](qabstractitemdelegate.html#setEditorData)()來填充從模型數據編輯器中,[setModelData](qabstractitemdelegate.html#setModelData)( ),使得代理可以更新模型以從編輯數據。 第二種方法是直接通過重新實現處理用戶事件[editorEvent](qabstractitemdelegate.html#editorEvent)( ) 。 * * * ## Type Documentation ``` QAbstractItemDelegate.EndEditHint ``` 這個枚舉變量描述了不同的提示,該委讬可以給模型和視圖組件使編輯數據的用戶模型中的舒適體驗。 | Constant | Value | Description | | --- | --- | --- | | `QAbstractItemDelegate.NoHint` | `0` | 沒有要執行建議的操作。 | 這些提示讓代表影響視圖的行為: | Constant | Value | Description | | --- | --- | --- | | `QAbstractItemDelegate.EditNextItem` | `1` | 認為應使用委讬在視圖中打開的下一個項目的編輯器。 | | `QAbstractItemDelegate.EditPreviousItem` | `2` | 認為應使用委讬在視圖中打開的前一個條目的編輯器。 | 請注意,自定義視圖可以解釋的下一個和以前不同的概念。 當模型被用于下面的提示是最有用的高速緩存數據,如那些在本地操作數據,以便提高性能或節約網絡帶寬。 | Constant | Value | Description | | --- | --- | --- | | `QAbstractItemDelegate.SubmitModelCache` | `3` | 如果模型緩存數據,它應該寫出來緩存數據到底層數據存儲。 | | `QAbstractItemDelegate.RevertModelCache` | `4` | 如果模型緩存數據,應該丟棄緩存數據,并將其與底層數據存儲的數據替換。 | 雖然模型和視圖應以適當方式對這些提示作出反應,自定義組件可能會忽略其中任何一個或全部,如果他們是不相關的。 * * * ## Method Documentation ``` QAbstractItemDelegate.__init__ (self, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 創建一個新的抽象項目委讬給定的_parent_。 ``` QWidget QAbstractItemDelegate.createEditor (self, QWidget?parent, QStyleOptionViewItem?option, QModelIndex?index) ``` [ 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 返回編輯器用于編輯的數據項與給定的_index_。請注意,該指數包含了所使用的模型信息。編輯器的父窗口部件被指定_parent_,且該項目由選項_option_。 該基地實現返回0 。如果你想自定義編輯,你需要重寫本函數。 ](qwidget.html) [返回編輯器部件應該有](qwidget.html)[Qt.StrongFocus](qt.html#FocusPolicy-enum)否則,[QMouseEvent](qmouseevent.html)由小工具收到的S將傳播到視圖。除非編輯器繪制自己的背景視圖的背景將彪炳(例如,用[setAutoFillBackground()](qwidget.html#autoFillBackground-prop)) 。 **See also** [setModelData](qabstractitemdelegate.html#setModelData)()和[setEditorData](qabstractitemdelegate.html#setEditorData)( ) 。 ``` bool QAbstractItemDelegate.editorEvent (self, QEvent?event, QAbstractItemModel?model, QStyleOptionViewItem?option, QModelIndex?index) ``` 的項目開始編輯時,這個函數被調用的_event_觸發編輯的_model_時,_index_該項目,并在_option_用于呈現的資料。 鼠標事件發送到editorEvent ( ),即使它們不啟動項目進行編輯。如果你想打開上下文菜單時,鼠標右鍵是在項目上按下這可以,例如,是有用的。 (表示它沒有處理的事件)基本實現返回False 。 ``` QString QAbstractItemDelegate.elidedText (QFontMetrics?fontMetrics, int?width, Qt.TextElideMode?mode, QString?text) ``` ``` bool QAbstractItemDelegate.helpEvent (self, QHelpEvent?event, QAbstractItemView?view, QStyleOptionViewItem?option, QModelIndex?index) ``` 這種方法也是一個Qt槽與C + +的簽名`bool helpEvent(QHelpEvent *,QAbstractItemView *,const QStyleOptionViewItem&,const QModelIndex&)`。 每當有幫助的事件發生時,這個函數被調用,_event_ _view_ _option_和_index_對應于其中發生該事件的資料。 返回True如果委讬可以處理該事件,否則返回False 。的返回值為True表示使用索引獲得的數據有必要的作用。 為[QEvent.ToolTip](qevent.html#Type-enum)和[QEvent.WhatsThis](qevent.html#Type-enum)已成功處理的事件時,有關彈出窗口可能取決于用戶的系統配置被顯示。 此功能被引入Qt的4.3 。 **See also** [QHelpEvent](qhelpevent.html)。 ``` QAbstractItemDelegate.paint (self, QPainter?painter, QStyleOptionViewItem?option, QModelIndex?index) ``` 這種方法是抽象的,應在任何子類中重新實現。 如果您想提供定制渲染這種純粹抽象函數必須被重新實現。使用_painter_和風格_option_呈現由該項目指定的項目_index_。 如果你重新實現這一點,你也必須重新實現[sizeHint](qabstractitemdelegate.html#sizeHint)( ) 。 ``` QAbstractItemDelegate.setEditorData (self, QWidget?editor, QModelIndex?index) ``` 設定的給定的內容_editor_以在給定的數據項_index_。請注意,該指數包含了所使用的模型信息。 基實現不執行任何操作。如果你想自定義編輯,你需要重寫本函數。 **See also** [setModelData](qabstractitemdelegate.html#setModelData)( ) 。 ``` QAbstractItemDelegate.setModelData (self, QWidget?editor, QAbstractItemModel?model, QModelIndex?index) ``` 設置項目的數據在給定的_index_在_model_到給定的內容_editor_。 基實現不執行任何操作。如果你想自定義編輯,你需要重寫本函數。 **See also** [setEditorData](qabstractitemdelegate.html#setEditorData)( ) 。 ``` QSize QAbstractItemDelegate.sizeHint (self, QStyleOptionViewItem?option, QModelIndex?index) ``` [ 這種方法是抽象的,應在任何子類中重新實現。 如果您想提供定制渲染這種純粹抽象函數必須被重新實現。該選項由指定_option_并通過模型項目_index_。 ](qsize.html) [如果你重新實現這一點,你也必須重新實現](qsize.html)[paint](qabstractitemdelegate.html#paint)( ) 。 ``` QAbstractItemDelegate.updateEditorGeometry (self, QWidget?editor, QStyleOptionViewItem?option, QModelIndex?index) ``` 更新的幾何_editor_與給定的項目_index_,根據在指定的矩形_option_。如果該項目有一個內部的布局,編輯器會相應布局。請注意,該指數包含了所使用的模型信息。 基實現不執行任何操作。如果你想自定義編輯你必須重新實現此功能。 * * * ## Qt Signal Documentation ``` void closeEditor (QWidget *,QAbstractItemDelegate::EndEditHint = QAbstractItemDelegate.NoHint) ``` 這是該信號的默認超載。 當用戶完成使用指定的編輯項目,該信號被發射_editor_。 該_hint_提供了一種方法的委讬來影響如何編輯后的模型和視圖的行為已經完成。這表明這些組件執行的動作旁,為用戶提供了舒適的編輯體驗進行。例如,如果`EditNextItem`被指定,視圖應該使用委讬來打開在模型中的下一個項目的編輯器。 **See also** [EndEditHint](qabstractitemdelegate.html#EndEditHint-enum)。 ``` void commitData (QWidget *) ``` 這是該信號的默認超載。 這個信號必須被發射時的_editor_小部件已經完成編輯數據,并希望將它寫回模式。 ``` void sizeHintChanged (const QModelIndex&) ``` 這是該信號的默認超載。 這個信號必須被發射時的[sizeHint](qabstractitemdelegate.html#sizeHint)的( )_index_改變。 視圖會自動連接到這個信號,并重新布局的項目是必要的。 此功能被引入Qt的4.4 。
                  <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>

                              哎呀哎呀视频在线观看