<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國際加速解決方案。 廣告
                # QItemDelegate Class Reference ## [[QtGui](index.htm) module] 該QItemDelegate類提供了從模型中的數據項的顯示和編輯功能。[More...](#details) 繼承[QAbstractItemDelegate](qabstractitemdelegate.html)。 通過繼承[QSqlRelationalDelegate](qsqlrelationaldelegate.html)。 ### Methods * `__init__ (self, QObject?parent?=?None)` * `QWidget createEditor (self, QWidget?parent, QStyleOptionViewItem?option, QModelIndex?index)` * `drawBackground (self, QPainter?painter, QStyleOptionViewItem?option, QModelIndex?index)` * `drawCheck (self, QPainter?painter, QStyleOptionViewItem?option, QRect?rect, Qt.CheckState?state)` * `drawDecoration (self, QPainter?painter, QStyleOptionViewItem?option, QRect?rect, QPixmap?pixmap)` * `drawDisplay (self, QPainter?painter, QStyleOptionViewItem?option, QRect?rect, QString?text)` * `drawFocus (self, QPainter?painter, QStyleOptionViewItem?option, QRect?rect)` * `bool editorEvent (self, QEvent?event, QAbstractItemModel?model, QStyleOptionViewItem?option, QModelIndex?index)` * `bool eventFilter (self, QObject?object, QEvent?event)` * `bool hasClipping (self)` * `QItemEditorFactory itemEditorFactory (self)` * `paint (self, QPainter?painter, QStyleOptionViewItem?option, QModelIndex?index)` * `setClipping (self, bool?clip)` * `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 該QItemDelegate類提供了從模型中的數據項的顯示和編輯功能。 QItemDelegate可用于基于項目視圖提供了自定義顯示功能和編輯器部件[QAbstractItemView](qabstractitemview.html)子類。使用委讬為此目的允許顯示和編輯機制,從模型和視圖定制和自主開發。 該QItemDelegate類是一個[Model/View Classes](index.htm)并且是Qt的一部分[model/view framework](index.htm)。需要注意的是[QStyledItemDelegate](qstyleditemdelegate.html)接管繪制Qt的項目視圖的工作。我們建議使用[QStyledItemDelegate](qstyleditemdelegate.html)創建新的委讬時。 當從一個標準視圖自定義模型顯示的項目,它往往是足夠簡單地確保模型返回相應的數據為每個[roles](qt.html#ItemDataRole-enum)確定項目的視圖的外觀。使用Qt的標準視圖中的默認代理使用這個角色信息中的大部分預期用戶的常見形式顯示項目。然而,有時需要有更多的控制比默認代理可以提供物品的外觀。 這個類提供了用于從項目模型視圖和編輯數據的繪畫項目數據的功能默認實現。的默認實現[paint](qitemdelegate.html#paint)()和[sizeHint](qitemdelegate.html#sizeHint)( )虛函數,定義[QAbstractItemDelegate](qabstractitemdelegate.html),提供了確保委讬實現了預期的看法正確的基本行為。您可以在子類中重新實現這些功能可以自定義項的外觀。 當一個項目視圖中編輯數據, QItemDelegate提供了一個編輯器部件,這是放置在視圖的頂部編輯時發生的一個小部件。編輯器都具有創建[QItemEditorFactory](qitemeditorfactory.html);通過提供一個默認的靜態實例[QItemEditorFactory](qitemeditorfactory.html)安裝在所有項目的代表。您可以使用設置一個自定義的工廠[setItemEditorFactory](qitemdelegate.html#setItemEditorFactory)( )或設置新的默認出廠帶[QItemEditorFactory.setDefaultFactory](qitemeditorfactory.html#setDefaultFactory)( ) 。它是存儲在項目模型與數據[Qt.EditRole](qt.html#ItemDataRole-enum)被編輯。 僅適用于部件為基礎的代表的標準編輯功能都在這里重新實現: * [createEditor](qitemdelegate.html#createEditor)() returns the widget used to change data from the model and can be reimplemented to customize editing behavior. * [setEditorData](qitemdelegate.html#setEditorData)() provides the widget with data to manipulate. * [updateEditorGeometry](qitemdelegate.html#updateEditorGeometry)() ensures that the editor is displayed correctly with respect to the item view. * [setModelData](qitemdelegate.html#setModelData)() returns updated data to the model. 該[closeEditor](qabstractitemdelegate.html#closeEditor)()信號表明用戶已經完成了編輯數據,并且該編輯器部件可以被摧毀。 ### Standard Roles and Data Types 通過使用Qt提供的標準視圖中的默認代理將每個標準角色(定義為[Qt.ItemDataRole](qt.html#ItemDataRole-enum))與某些數據類型。模型返回的數據在這些類型可以影響代表的,如下表中所述的外觀。 | 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) 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) | 如果默認的委讬不允許你需要的定制化水平,無論是用于顯示目的或編輯數據,就可以繼承QItemDelegate實施所需的行為。 ### Subclassing 當子類QItemDelegate創建一個使用自定義渲染器顯示的項目委讬,重要的是要確保委讬可以適當渲染項目所需的所有國家;如選擇禁用,檢查。該文檔為[paint](qitemdelegate.html#paint)( )函數包含一些提示,說明如何可以做到這一點。 您可以通過使用一個提供自定義編輯器[QItemEditorFactory](qitemeditorfactory.html)。該[Color Editor Factory Example](index.htm)展示了如何自定義編輯器,可以提供給與會代表使用默認項目編輯器的工廠。這樣一來,就沒有必要向子類QItemDelegate 。另一種方法是重新實現[createEditor](qitemdelegate.html#createEditor)( )[setEditorData](qitemdelegate.html#setEditorData)( )[setModelData](qitemdelegate.html#setModelData)()和[updateEditorGeometry](qitemdelegate.html#updateEditorGeometry)( ) 。這個過程是在所描述的[Spin Box Delegate Example](index.htm)。 ### QStyledItemDelegate vs. QItemDelegate 由于Qt的4.4 ,有兩個委讬類: QItemDelegate和[QStyledItemDelegate](qstyleditemdelegate.html)。不過,默認的委讬是[QStyledItemDelegate](qstyleditemdelegate.html)。這兩個類是獨立的替代品來畫,并提供編輯器的項目中的觀點。它們之間的不同之處在于[QStyledItemDelegate](qstyleditemdelegate.html)使用當前的樣式來繪制它的項目。因此,我們建議您使用[QStyledItemDelegate](qstyleditemdelegate.html)作為基類實現自定義委讬或與Qt樣式表時,工作時。需要的不是類的代碼應該是平等的,除非自定義委讬需要使用的樣式繪制。 * * * ## Method Documentation ``` QItemDelegate.__init__ (self, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 構造一個項目委讬給定的_parent_。 ``` QWidget QItemDelegate.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)( ) 。 ``` QItemDelegate.drawBackground (self, QPainter?painter, QStyleOptionViewItem?option, QModelIndex?index) ``` 呈現項目背景為給定的_index_,使用給定的_painter_和風格_option_。 這個函數中引入了Qt 4.2中。 ``` QItemDelegate.drawCheck (self, QPainter?painter, QStyleOptionViewItem?option, QRect?rect, Qt.CheckState?state) ``` 呈現由指定的矩形內的檢查指標_rect_,使用給定的_painter_和風格_option_,使用給定的_state_。 ``` QItemDelegate.drawDecoration (self, QPainter?painter, QStyleOptionViewItem?option, QRect?rect, QPixmap?pixmap) ``` 渲染裝飾_pixmap_由指定的矩形內_rect_使用給定的_painter_和風格_option_。 ``` QItemDelegate.drawDisplay (self, QPainter?painter, QStyleOptionViewItem?option, QRect?rect, QString?text) ``` 呈現項目視圖_text_由指定的矩形內_rect_使用給定的_painter_和風格_option_。 ``` QItemDelegate.drawFocus (self, QPainter?painter, QStyleOptionViewItem?option, QRect?rect) ``` 呈現由指定的矩形區域內的_rect_,這表明它具有焦點,使用給定的_painter_和風格_option_。 ``` bool QItemDelegate.editorEvent (self, QEvent?event, QAbstractItemModel?model, QStyleOptionViewItem?option, QModelIndex?index) ``` 從重新實現[QAbstractItemDelegate.editorEvent](qabstractitemdelegate.html#editorEvent)( ) 。 ``` bool QItemDelegate.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)( ) 。 ``` bool QItemDelegate.hasClipping (self) ``` ``` QItemEditorFactory QItemDelegate.itemEditorFactory (self) ``` [ 返回使用的項目委讬編輯工廠。如果沒有編輯器出廠設置,該函數將返回null 。 ](qitemeditorfactory.html) [**See also**](qitemeditorfactory.html) [setItemEditorFactory](qitemdelegate.html#setItemEditorFactory)( ) 。 ``` QItemDelegate.paint (self, QPainter?painter, QStyleOptionViewItem?option, QModelIndex?index) ``` 從重新實現[QAbstractItemDelegate.paint](qabstractitemdelegate.html#paint)( ) 。 使用給定的呈現委讬_painter_和風格_option_由指定的項目_index_。 當重新實現在子類中這個功能,你應該更新的選項持的區域[rect](qstyleoption.html#rect-var)變量,使用選項的[state](qstyleoption.html#state-var)變量來確定要顯示的項的狀態,并調整其相應繪的方式。 例如,所選擇的項目,可能需要不同地未被選擇的項目顯示,如顯示在下面的代碼: ``` if (option.state & [QStyle](qstyle.html).State_Selected) painter->fillRect(option.rect, option.palette.highlight()); int size = qMin(option.rect.width(), option.rect.height()); int brightness = index.model()->data(index, [Qt](qt.html).DisplayRole).toInt(); double radius = (size/2.0) - (brightness/255.0 * size/2.0); if (radius == 0.0) return; painter->save(); painter->setRenderHint([QPainter](qpainter.html).Antialiasing, true); painter->setPen([Qt](qt.html).NoPen); if (option.state & [QStyle](qstyle.html).State_Selected) painter->setBrush(option.palette.highlightedText()); else ... ``` 噴漆后,您應確保畫家返回到其它時,這個函數被調用的供給狀態。例如,它可能是有用的呼叫[QPainter.save](qpainter.html#save)( )之前,繪畫和[QPainter.restore](qpainter.html#restore)( )之后。 **See also** [QStyle.State](qstyle.html#StateFlag-enum)。 ``` QItemDelegate.setClipping (self, bool?clip) ``` ``` QItemDelegate.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)( ) 。 ``` QItemDelegate.setItemEditorFactory (self, QItemEditorFactory?factory) ``` 設置編輯工廠中使用的項目的委讬是_factory_規定。如果沒有編輯器出廠設置,該項目代表將使用默認編輯器工廠。 **See also** [itemEditorFactory](qitemdelegate.html#itemEditorFactory)( ) 。 ``` QItemDelegate.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 QItemDelegate.sizeHint (self, QStyleOptionViewItem?option, QModelIndex?index) ``` [](qsize.html) [從重新實現](qsize.html)[QAbstractItemDelegate.sizeHint](qabstractitemdelegate.html#sizeHint)( ) 。 返回顯示由指定的項目需要由委讬的大小_index_考慮到所提供的樣式信息_option_。 當重新實現此功能,請注意,在案件的文本項,[QItemDelegate](qitemdelegate.html)增加了利潤率(即2 *[QStyle.PM_FocusFrameHMargin](qstyle.html#PixelMetric-enum))以文本的長度。 ``` QItemDelegate.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>

                              哎呀哎呀视频在线观看