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

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # QStyledItemDelegate Class Reference ## [[QtGui](index.htm) module] 該QStyledItemDelegate類提供了從模型中的數據項的顯示和編輯功能。[More...](#details) 繼承[QAbstractItemDelegate](qabstractitemdelegate.html)。 ### Methods * `__init__ (self, QObject?parent?=?None)` * `QWidget createEditor (self, QWidget?parent, QStyleOptionViewItem?option, QModelIndex?index)` * `QString displayText (self, QVariant?value, QLocale?locale)` * `bool editorEvent (self, QEvent?event, QAbstractItemModel?model, QStyleOptionViewItem?option, QModelIndex?index)` * `bool eventFilter (self, QObject?object, QEvent?event)` * `initStyleOption (self, QStyleOptionViewItem?option, QModelIndex?index)` * `QItemEditorFactory itemEditorFactory (self)` * `paint (self, QPainter?painter, QStyleOptionViewItem?option, QModelIndex?index)` * `setEditorData (self, QWidget?editor, QModelIndex?index)` * `setItemEditorFactory (self, QItemEditorFactory?factory)` * `setModelData (self, QWidget?editor, QAbstractItemModel?model, QModelIndex?index)` * `QSize sizeHint (self, QStyleOptionViewItem?option, QModelIndex?index)` * `updateEditorGeometry (self, QWidget?editor, QStyleOptionViewItem?option, QModelIndex?index)` * * * ## Detailed Description 該QStyledItemDelegate類提供了從模型中的數據項的顯示和編輯功能。 當顯示從模型數據中的Qt項目的意見,例如,一個[QTableView](qtableview.html),個別項目被委讬繪制。此外,當一個項目被編輯時,它提供了一個編輯器窗口小部件,它被放置在項目視圖的頂部,同時編輯發生的位置。 QStyledItemDelegate是默認的委讬對所有的Qt項目的意見,并在安裝后,他們在創建時。 該QStyledItemDelegate類是一個[Model/View Classes](index.htm)并且是Qt的一部分[model/view framework](index.htm)。委讬允許項的顯示和編輯,以獨立于模型和視圖開發的。 在模型項的數據分配一個[ItemDataRole](qt.html#ItemDataRole-enum);每個項目可以存儲[QVariant](qvariant.html)為每個角色。 QStyledItemDelegate實現顯示和編輯的預期用戶最常用的數據類型,包括布爾,整數和字符串。 這些數據將被繪制不同,這取決于他們在模型中的作用。下表描述的角色和數據類型的委讬可以處理它們。它往往是足以確保模型返回每個角色的適當的數據,以確定項目的意見的外觀。 | Role | Accepted Types | | --- | --- | | [Qt.BackgroundRole](qt.html#ItemDataRole-enum) | [QBrush](qbrush.html) | | [Qt.BackgroundColorRole](qt.html#ItemDataRole-enum) | [QColor](qcolor.html) (obsolete; use [Qt.BackgroundRole](qt.html#ItemDataRole-enum) instead) | | [Qt.CheckStateRole](qt.html#ItemDataRole-enum) | [Qt.CheckState](qt.html#CheckState-enum) | | [Qt.DecorationRole](qt.html#ItemDataRole-enum) | [QIcon](qicon.html), [QPixmap](qpixmap.html), [QImage](qimage.html) and [QColor](qcolor.html) | | [Qt.DisplayRole](qt.html#ItemDataRole-enum) | [QString](qstring.html) and types with a string representation | | [Qt.EditRole](qt.html#ItemDataRole-enum) | See [QItemEditorFactory](qitemeditorfactory.html) for details | | [Qt.FontRole](qt.html#ItemDataRole-enum) | [QFont](qfont.html) | | [Qt.SizeHintRole](qt.html#ItemDataRole-enum) | [QSize](qsize.html) | | [Qt.TextAlignmentRole](qt.html#ItemDataRole-enum) | [Qt.Alignment](qt.html#AlignmentFlag-enum) | | [Qt.ForegroundRole](qt.html#ItemDataRole-enum) | [QBrush](qbrush.html) | | [Qt.TextColorRole](qt.html#ItemDataRole-enum) | [QColor](qcolor.html) (obsolete; use [Qt.ForegroundRole](qt.html#ItemDataRole-enum) instead) | 編輯器都具有創建[QItemEditorFactory](qitemeditorfactory.html);通過提供一個默認的靜態實例[QItemEditorFactory](qitemeditorfactory.html)安裝在所有項目的代表。您可以使用設置一個自定義的工廠[setItemEditorFactory](qstyleditemdelegate.html#setItemEditorFactory)( )或設置新的默認出廠帶[QItemEditorFactory.setDefaultFactory](qitemeditorfactory.html#setDefaultFactory)( ) 。它是存儲在項目模型與數據[EditRole](qt.html#ItemDataRole-enum)被編輯。請參閱[QItemEditorFactory](qitemeditorfactory.html)類為更高層的介紹項目編輯器的工廠。該[Color Editor Factory](index.htm)示例顯示了如何創建自定義編輯器的工廠。 ### Subclassing QStyledItemDelegate 如果代理不支持繪畫你需要的數據類型,或者您要自定義項目的圖紙,你需要繼承QStyledItemDelegate ,并重新實現[paint](qstyleditemdelegate.html#paint)( )和可能[sizeHint](qstyleditemdelegate.html#sizeHint)( ) 。該[paint](qstyleditemdelegate.html#paint)()函數被單獨地調用的每個項目,并與[sizeHint](qstyleditemdelegate.html#sizeHint)( ) ,您可以為每個人指定的提示。 當重新實現[paint](qstyleditemdelegate.html#paint)( ) ,人們通常會處理的數據類型一想繪制和使用超類實現其他類型。 的復選框指標的繪畫是由當前樣式進行。樣式還指定了大小和邊界矩形在其中繪制的數據不同的數據的作用。項目本身的邊框也被計算的風格。當圖紙已經支持的數據類型,因此它是一個好主意,要求風格這些邊界矩形。該[QStyle](qstyle.html)類的描述更詳細地描述這一點。 如果你想改變任何通過復選框指標的樣式或繪畫計算的邊界矩形的,你可以繼承[QStyle](qstyle.html)。但是請注意,這些項的大小也可以受到重新實現[sizeHint](qstyleditemdelegate.html#sizeHint)( ) 。 這是可能的自定義委讬來提供編輯器,無需使用一個編輯器項目工廠。在這種情況下,下面的虛函數必須被重新實現: * [createEditor](qstyleditemdelegate.html#createEditor)() returns the widget used to change data from the model and can be reimplemented to customize editing behavior. * [setEditorData](qstyleditemdelegate.html#setEditorData)() provides the widget with data to manipulate. * [updateEditorGeometry](qstyleditemdelegate.html#updateEditorGeometry)() ensures that the editor is displayed correctly with respect to the item view. * [setModelData](qstyleditemdelegate.html#setModelData)() returns updated data to the model. 該[Star Delegate](index.htm)例如,通過重新實現這些方法創建編輯器。 ### QStyledItemDelegate vs. QItemDelegate 由于Qt的4.4 ,有兩個委讬類:[QItemDelegate](qitemdelegate.html)和QStyledItemDelegate 。不過,默認的委讬是QStyledItemDelegate 。這兩個類是獨立的替代品來畫,并提供編輯器的項目中的觀點。它們之間的區別在于QStyledItemDelegate使用當前樣式來繪制它的項目。因此,我們建議實現自定義委讬或與Qt樣式表工作時,在使用QStyledItemDelegate作為基類。需要的不是類的代碼應該是平等的,除非自定義委讬需要使用的樣式繪制。 如果你想自定義的項目意見的畫,你應該實現一個自定義樣式。請參閱[QStyle](qstyle.html)類文檔。 * * * ## Method Documentation ``` QStyledItemDelegate.__init__ (self, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 構造一個項目委讬給定的_parent_。 ``` QWidget QStyledItemDelegate.createEditor (self, QWidget?parent, QStyleOptionViewItem?option, QModelIndex?index) ``` [ 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 ](qwidget.html) [從重新實現](qwidget.html)[QAbstractItemDelegate.createEditor](qabstractitemdelegate.html#createEditor)( ) 。 返回用于編輯由指定的項目小組件_index_進行編輯。該_parent_小工具和風格_option_用于控制如何顯示在編輯器部件。 **See also** [QAbstractItemDelegate.createEditor](qabstractitemdelegate.html#createEditor)( ) 。 ``` QString QStyledItemDelegate.displayText (self, QVariant?value, QLocale?locale) ``` 該函數返回一個委讬將用于顯示的字符串[Qt.DisplayRole](qt.html#ItemDataRole-enum)該模型中的_locale_。_value_是的價值[Qt.DisplayRole](qt.html#ItemDataRole-enum)提供的模型。 默認實現使用的QLocale.toString轉換_value_成[QString](qstring.html)。 這個功能沒有要求空模型指數,即指數的模型返回一個無效[QVariant](qvariant.html)。 **See also** [QAbstractItemModel.data](qabstractitemmodel.html#data)( ) 。 ``` bool QStyledItemDelegate.editorEvent (self, QEvent?event, QAbstractItemModel?model, QStyleOptionViewItem?option, QModelIndex?index) ``` 從重新實現[QAbstractItemDelegate.editorEvent](qabstractitemdelegate.html#editorEvent)( ) 。 ``` bool QStyledItemDelegate.eventFilter (self, QObject?object, QEvent?event) ``` 從重新實現[QObject.eventFilter](qobject.html#eventFilter)( ) 。 返回True如果給定的_editor_是一個有效的[QWidget](qwidget.html)和給定的_event_處理,否則返回False 。下面的按鍵事件在默認情況下的處理: * **Tab** * **Backtab** * **Enter** * **Return** * **Esc** 在的情況下**Tab**,**Backtab**,**Enter**和**Return**按鍵事件,_editor_的數據被COMITTED到模型和編輯器被關閉。如果_event_是**Tab**按鍵的視圖將在視圖上的下一個項目打開一個編輯器。同樣地,如果_event_是**Backtab**按鍵視圖將在打開一個編輯器_previous_在視圖中的項目。 如果該事件是**Esc**按鍵事件時,_editor_關閉_without_提交其數據。 **See also** [commitData](qabstractitemdelegate.html#commitData)()和[closeEditor](qabstractitemdelegate.html#closeEditor)( ) 。 ``` QStyledItemDelegate.initStyleOption (self, QStyleOptionViewItem?option, QModelIndex?index) ``` 初始化_option_與使用索引值_index_。當他們需要一個這種方法是有用的子類[QStyleOptionViewItem](qstyleoptionviewitem.html),但不希望在所有的信息填寫自己。此功能將檢查的版本[QStyleOptionViewItem](qstyleoptionviewitem.html)并填寫了附加價值[QStyleOptionViewItemV2](qstyleoptionviewitemv2.html),[QStyleOptionViewItemV3](qstyleoptionviewitemv3.html)和[QStyleOptionViewItemV4](qstyleoptionviewitemv4.html)。 **See also** [QStyleOption.initFrom](qstyleoption.html#initFrom)( ) 。 ``` QItemEditorFactory QStyledItemDelegate.itemEditorFactory (self) ``` [ 返回使用的項目委讬編輯工廠。如果沒有編輯器出廠設置,該函數將返回null 。 ](qitemeditorfactory.html) [**See also**](qitemeditorfactory.html) [setItemEditorFactory](qstyleditemdelegate.html#setItemEditorFactory)( ) 。 ``` QStyledItemDelegate.paint (self, QPainter?painter, QStyleOptionViewItem?option, QModelIndex?index) ``` 從重新實現[QAbstractItemDelegate.paint](qabstractitemdelegate.html#paint)( ) 。 使用給定的呈現委讬_painter_和風格_option_由指定的項目_index_。 使用視圖的此功能涂料項目[QStyle](qstyle.html)。 當在子類中重新實現的油漆。使用[initStyleOption](qstyleditemdelegate.html#initStyleOption)( )來設置_option_以同樣的方式作為[QStyledItemDelegate](qstyleditemdelegate.html);該選項將始終是一個實例[QStyleOptionViewItemV4](qstyleoptionviewitemv4.html)。請參閱其類描述其內容的信息。 只要有可能,使用_option_而畫。尤其是其[rect](qstyleoption.html#rect-var)變量來決定在哪里繪制和其[state](qstyleoption.html#state-var)以確定它是否被啟用或選定。 噴漆后,您應確保畫家返回到其它時,這個函數被調用的供給狀態。例如,它可能是有用的呼叫[QPainter.save](qpainter.html#save)( )之前,繪畫和[QPainter.restore](qpainter.html#restore)( )之后。 **See also** [QItemDelegate.paint](qitemdelegate.html#paint)( )[QStyle.drawControl](qstyle.html#drawControl)()和[QStyle.CE_ItemViewItem](qstyle.html#ControlElement-enum)。 ``` QStyledItemDelegate.setEditorData (self, QWidget?editor, QModelIndex?index) ``` 從重新實現[QAbstractItemDelegate.setEditorData](qabstractitemdelegate.html#setEditorData)( ) 。 設置由顯示和編輯數據_editor_從模型中指定的數據模型項目_index_。 默認實現存儲在數據_editor_widget的[user property](index.htm#qt-s-property-system)。 **See also** [QMetaProperty.isUser](qmetaproperty.html#isUser)( ) 。 ``` QStyledItemDelegate.setItemEditorFactory (self, QItemEditorFactory?factory) ``` 設置編輯工廠中使用的項目的委讬是_factory_規定。如果沒有編輯器出廠設置,該項目代表將使用默認編輯器工廠。 **See also** [itemEditorFactory](qstyleditemdelegate.html#itemEditorFactory)( ) 。 ``` QStyledItemDelegate.setModelData (self, QWidget?editor, QAbstractItemModel?model, QModelIndex?index) ``` 從重新實現[QAbstractItemDelegate.setModelData](qabstractitemdelegate.html#setModelData)( ) 。 獲取數據從_editor_插件和將其存儲在指定的_model_在項目_index_。 默認實現得到的值也可以從存儲在數據模型_editor_widget的[user property](index.htm#qt-s-property-system)。 **See also** [QMetaProperty.isUser](qmetaproperty.html#isUser)( ) 。 ``` QSize QStyledItemDelegate.sizeHint (self, QStyleOptionViewItem?option, QModelIndex?index) ``` [](qsize.html) [從重新實現](qsize.html)[QAbstractItemDelegate.sizeHint](qabstractitemdelegate.html#sizeHint)( ) 。 返回顯示由指定的項目需要由委讬的大小_index_考慮到所提供的樣式信息_option_。 該函數使用視圖的[QStyle](qstyle.html)以確定該項目的大小。 **See also** [QStyle.sizeFromContents](qstyle.html#sizeFromContents)()和[QStyle.CT_ItemViewItem](qstyle.html#ContentsType-enum)。 ``` QStyledItemDelegate.updateEditorGeometry (self, QWidget?editor, QStyleOptionViewItem?option, QModelIndex?index) ``` 從重新實現[QAbstractItemDelegate.updateEditorGeometry](qabstractitemdelegate.html#updateEditorGeometry)( ) 。 更新_editor_由指定的項目_index_根據風格_option_給出。
                  <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>

                              哎呀哎呀视频在线观看