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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # QDataWidgetMapper Class Reference ## [[QtGui](index.htm) module] 該QDataWidgetMapper類提供了一個數據模型,以小部件的部分之間的映射。[More...](#details) 繼承[QObject](qobject.html)。 ### Types * `enum SubmitPolicy { AutoSubmit, ManualSubmit }` ### Methods * `__init__ (self, QObject?parent?=?None)` * `addMapping (self, QWidget?widget, int?section)` * `addMapping (self, QWidget?widget, int?section, QByteArray?propertyName)` * `clearMapping (self)` * `int currentIndex (self)` * `QAbstractItemDelegate itemDelegate (self)` * `QByteArray mappedPropertyName (self, QWidget?widget)` * `int mappedSection (self, QWidget?widget)` * `QWidget mappedWidgetAt (self, int?section)` * `QAbstractItemModel model (self)` * `Qt.Orientation orientation (self)` * `removeMapping (self, QWidget?widget)` * `revert (self)` * `QModelIndex rootIndex (self)` * `setCurrentIndex (self, int?index)` * `setCurrentModelIndex (self, QModelIndex?index)` * `setItemDelegate (self, QAbstractItemDelegate?delegate)` * `setModel (self, QAbstractItemModel?model)` * `setOrientation (self, Qt.Orientation?aOrientation)` * `setRootIndex (self, QModelIndex?index)` * `setSubmitPolicy (self, SubmitPolicy?policy)` * `bool submit (self)` * `SubmitPolicy submitPolicy (self)` * `toFirst (self)` * `toLast (self)` * `toNext (self)` * `toPrevious (self)` ### Qt Signals * `void currentIndexChanged (int)` * * * ## Detailed Description 該QDataWidgetMapper類提供了一個數據模型,以小部件的部分之間的映射。 QDataWidgetMapper可以使用它們映射到的項目模型部分來創建數據感知部件。 A節是模型中的列,如果方向是水平的(默認值) ,否則一排。 每當當前指數的變化,每個插件是通過在它的映射被做了指定的屬性從模型數據更新。如果用戶編輯窗口小部件的內容,使用相同的屬性被讀取和寫回模型的變更。默認情況下,每個插件的[user property](qobject.html#Q_PROPERTY)用于傳輸的模型和部件之間的數據。由于Qt的4.3 ,額外的[addMapping](qdatawidgetmapper.html#addMapping)( )函數使一個名為屬性,而不是默認的用戶屬性來使用。 它可以設定的項目委讬,支持自定義窗口小部件。默認情況下,[QItemDelegate](qitemdelegate.html)用于同步模式與窗口小部件。 讓我們假設我們有一個名為項目模型`model`其內容如下: | 1 | Qt Norway | Oslo | | 2 | Qt Australia | Brisbane | | 3 | Qt USA | Palo Alto | | 4 | Qt China | Beijing | | 5 | Qt Germany | Berlin | 下面的代碼將模型中的列映射到部件稱為`mySpinBox`,`myLineEdit`和`myCountryChooser`: ``` QDataWidgetMapper *mapper = new QDataWidgetMapper; mapper->setModel(model); mapper->addMapping(mySpinBox, 0); mapper->addMapping(myLineEdit, 1); mapper->addMapping(myCountryChooser, 2); mapper->toFirst(); ``` 在調用后,[toFirst](qdatawidgetmapper.html#toFirst)( )`mySpinBox`顯示值`1`,`myLineEdit`顯示器`Qt Norway`和`myCountryChooser`顯示器`Oslo`。導航功能[toFirst](qdatawidgetmapper.html#toFirst)( )[toNext](qdatawidgetmapper.html#toNext)( )[toPrevious](qdatawidgetmapper.html#toPrevious)( )[toLast](qdatawidgetmapper.html#toLast)()和[setCurrentIndex](qdatawidgetmapper.html#currentIndex-prop)()可以被用于導航模型中,并與從模型內容更新部件。 該[setRootIndex](qdatawidgetmapper.html#setRootIndex)( )函數實現了特定的項目中被指定為根指數的模型 - 這資料的孩子會被映射到用戶界面相關的部件。 QDataWidgetMapper支持兩種提交的政策,`AutoSubmit`和`ManualSubmit`。`AutoSubmit`將盡快更新模型作為當前控件失去焦點,`ManualSubmit`不會更新模型,除非[submit](qdatawidgetmapper.html#submit)()被調用。`ManualSubmit`顯示一個對話框,允許用戶取消所有修改的時候非常有用。此外,該顯示模型的其他視圖將不會更新,直到用戶完成所有的修改和提交。 需要注意的是QDataWidgetMapper跟蹤外部修改。如果模型的內容??的應用程序的另一個模塊被更新時,窗口小部件被更新。 * * * ## Type Documentation ``` QDataWidgetMapper.SubmitPolicy ``` 這個枚舉變量描述了可能的提交政策[QDataWidgetMapper](qdatawidgetmapper.html)支持。 | Constant | Value | Description | | --- | --- | --- | | `QDataWidgetMapper.AutoSubmit` | `0` | 每當一個widget失去焦點時,控件的當前值設置為項目的模型。 | | `QDataWidgetMapper.ManualSubmit` | `1` | 該模型不更新,直到[submit](qdatawidgetmapper.html#submit)()被調用。 | * * * ## Method Documentation ``` QDataWidgetMapper.__init__ (self, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 構造一個新的[QDataWidgetMapper](qdatawidgetmapper.html)與父對象_parent_。默認情況下,方向是水平的,而提交政策`AutoSubmit`。 **See also** [setOrientation](qdatawidgetmapper.html#orientation-prop)()和[setSubmitPolicy](qdatawidgetmapper.html#submitPolicy-prop)( ) 。 ``` QDataWidgetMapper.addMapping (self, QWidget?widget, int?section) ``` 增加了之間的映射_widget_和_section_從模型。該_section_在模型中的列,如果方向是水平的(缺省設置) ,否則一排。 在下面的例子中,我們假設一個模型`myModel`有兩列:第一包含的人在一組的名稱,第二列包含他們的年齡。第一列被映射到[QLineEdit](qlineedit.html) `nameLineEdit`以及第二映射到[QSpinBox](qspinbox.html) `ageSpinBox`: ``` [QDataWidgetMapper](qdatawidgetmapper.html) *mapper = new [QDataWidgetMapper](qdatawidgetmapper.html)(); mapper->setModel(myModel); mapper->addMapping(nameLineEdit, 0); mapper->addMapping(ageSpinBox, 1); ``` **Notes:** * If the _widget_ is already mapped to a section, the old mapping will be replaced by the new one. * Only one-to-one mappings between sections and widgets are allowed. It is not possible to map a single section to multiple widgets, or to map a single widget to multiple sections. **See also** [removeMapping](qdatawidgetmapper.html#removeMapping)( )[mappedSection](qdatawidgetmapper.html#mappedSection)()和[clearMapping](qdatawidgetmapper.html#clearMapping)( ) 。 ``` QDataWidgetMapper.addMapping (self, QWidget?widget, int?section, QByteArray?propertyName) ``` 本質上是相同[addMapping](qdatawidgetmapper.html#addMapping)( ) ,但增加了指定的屬性來指定使用的可能性_propertyName_。 此功能被引入Qt的4.3 。 **See also** [addMapping](qdatawidgetmapper.html#addMapping)( ) 。 ``` QDataWidgetMapper.clearMapping (self) ``` 清除所有映射。 **See also** [addMapping](qdatawidgetmapper.html#addMapping)()和[removeMapping](qdatawidgetmapper.html#removeMapping)( ) 。 ``` int QDataWidgetMapper.currentIndex (self) ``` ``` QAbstractItemDelegate QDataWidgetMapper.itemDelegate (self) ``` [ 返回當前項目委讬。 ](qabstractitemdelegate.html) [**See also**](qabstractitemdelegate.html) [setItemDelegate](qdatawidgetmapper.html#setItemDelegate)( ) 。 ``` QByteArray QDataWidgetMapper.mappedPropertyName (self, QWidget?widget) ``` [ 返回被映射的數據時使用的屬性的名稱,以給定的_widget_。 此功能被引入Qt的4.3 。 ](qbytearray.html) [**See also**](qbytearray.html) [mappedSection](qdatawidgetmapper.html#mappedSection)( )[addMapping](qdatawidgetmapper.html#addMapping)()和[removeMapping](qdatawidgetmapper.html#removeMapping)( ) 。 ``` int QDataWidgetMapper.mappedSection (self, QWidget?widget) ``` 返回節_widget_被映射到或-1,如果小部件不被映射。 **See also** [addMapping](qdatawidgetmapper.html#addMapping)()和[removeMapping](qdatawidgetmapper.html#removeMapping)( ) 。 ``` QWidget QDataWidgetMapper.mappedWidgetAt (self, int?section) ``` [ 返回映射在小部件_section_,或者0 ,如果沒有部件被映射在該節。 ](qwidget.html) [**See also**](qwidget.html) [addMapping](qdatawidgetmapper.html#addMapping)()和[removeMapping](qdatawidgetmapper.html#removeMapping)( ) 。 ``` QAbstractItemModel QDataWidgetMapper.model (self) ``` [ 返回當前的模式。 ](qabstractitemmodel.html) [**See also**](qabstractitemmodel.html) [setModel](qdatawidgetmapper.html#setModel)( ) 。 ``` Qt.Orientation QDataWidgetMapper.orientation (self) ``` [ ``` QDataWidgetMapper.removeMapping (self, QWidget?widget) ``` 刪除映射為給定的_widget_。 ](qt.html#Orientation-enum) [**See also**](qt.html#Orientation-enum) [addMapping](qdatawidgetmapper.html#addMapping)()和[clearMapping](qdatawidgetmapper.html#clearMapping)( ) 。 ``` QDataWidgetMapper.revert (self) ``` 這種方法也是一個Qt槽與C + +的簽名`void revert()`。 重新填充所有部件與模型的當前數據。所有未提交的更改將會丟失。 **See also** [submit](qdatawidgetmapper.html#submit)()和[setSubmitPolicy](qdatawidgetmapper.html#submitPolicy-prop)( ) 。 ``` QModelIndex QDataWidgetMapper.rootIndex (self) ``` [ 返回當前根索引。 ](qmodelindex.html) [**See also**](qmodelindex.html) [setRootIndex](qdatawidgetmapper.html#setRootIndex)( ) 。 ``` QDataWidgetMapper.setCurrentIndex (self, int?index) ``` 這種方法也是一個Qt槽與C + +的簽名`void setCurrentIndex(int)`。 ``` QDataWidgetMapper.setCurrentModelIndex (self, QModelIndex?index) ``` 這種方法也是一個Qt槽與C + +的簽名`void setCurrentModelIndex(const QModelIndex&)`。 設置當前索引的行_index_如果方向是水平的(默認值) ,否則到的列_index_。 電話[setCurrentIndex](qdatawidgetmapper.html#currentIndex-prop)(內部) 。這便利槽可連接到所述信號[currentRowChanged()](qitemselectionmodel.html#currentRowChanged) or [currentColumnChanged()](qitemselectionmodel.html#currentColumnChanged)另一種觀點認為年代[selection model](qitemselectionmodel.html)。 下面的例子演示了如何更新所有的widget與新數據時的選擇[QTableView](qtableview.html) named `myTableView`變化: ``` [QDataWidgetMapper](qdatawidgetmapper.html) *mapper = new [QDataWidgetMapper](qdatawidgetmapper.html)(); connect(myTableView->selectionModel(), SIGNAL(currentRowChanged([QModelIndex](qmodelindex.html),[QModelIndex](qmodelindex.html))), mapper, SLOT(setCurrentModelIndex([QModelIndex](qmodelindex.html)))); ``` **See also** [currentIndex](qdatawidgetmapper.html#currentIndex-prop)( ) 。 ``` QDataWidgetMapper.setItemDelegate (self, QAbstractItemDelegate?delegate) ``` 設置項委讬_delegate_。該委讬將用于從模型數據寫入到窗口小部件,并從部件的模型,用[QAbstractItemDelegate.setEditorData](qabstractitemdelegate.html#setEditorData)()和[QAbstractItemDelegate.setModelData](qabstractitemdelegate.html#setModelData)( ) 。 該代表還決定何時應用數據以及何時改變編輯器,使用[QAbstractItemDelegate.commitData](qabstractitemdelegate.html#commitData)()和[QAbstractItemDelegate.closeEditor](qabstractitemdelegate.html#closeEditor)( ) 。 **Warning:**你不應該共享控件映射程序或視圖之間的委讬的同一實例。否則會導致不正確或不直觀的編輯行為,因為在一個給定的委讬每個視圖可能會收到[closeEditor()](qabstractitemdelegate.html#closeEditor)信號,并試圖訪問,修改或關閉一個已經被關閉的編輯器。 **See also** [itemDelegate](qdatawidgetmapper.html#itemDelegate)( ) 。 ``` QDataWidgetMapper.setModel (self, QAbstractItemModel?model) ``` 目前的模式設置為_model_。如果設置了另一種模式,所有映射到舊的模式被清除。 **See also** [model](qdatawidgetmapper.html#model)( ) 。 ``` QDataWidgetMapper.setOrientation (self, Qt.Orientation?aOrientation) ``` ``` QDataWidgetMapper.setRootIndex (self, QModelIndex?index) ``` 根項目設置為_index_。這可以被用來顯示一個樹的分支。傳遞一個無效的模型索引來顯示最上面的分支。 **See also** [rootIndex](qdatawidgetmapper.html#rootIndex)( ) 。 ``` QDataWidgetMapper.setSubmitPolicy (self, SubmitPolicy?policy) ``` ``` bool QDataWidgetMapper.submit (self) ``` 這種方法也是一個Qt槽與C + +的簽名`bool submit()`。 從提交的映射部件的所有更改到模型中。 對于每一個映射部,該項目委讬從窗口小部件讀取的當前值,并將其設置在模型中。最后,該模型是[submit()](qabstractitemmodel.html#submit)方法被調用。 如果所有的值被提交,否則為False ,則返回True 。 注意:對于數據庫模型,[QSqlQueryModel.lastError](qsqlquerymodel.html#lastError)( )可以用來獲取最后一個錯誤。 **See also** [revert](qdatawidgetmapper.html#revert)()和[setSubmitPolicy](qdatawidgetmapper.html#submitPolicy-prop)( ) 。 ``` SubmitPolicy QDataWidgetMapper.submitPolicy (self) ``` [ ``` QDataWidgetMapper.toFirst (self) ``` 這種方法也是一個Qt槽與C + +的簽名`void toFirst()`。 填充部件與從模型中的第一行的數據,如果方向是水平的(缺省設置) ,否則從第一列中的數據。 這等同于調用`setCurrentIndex(0)`。 ](qdatawidgetmapper.html#SubmitPolicy-enum) [**See also**](qdatawidgetmapper.html#SubmitPolicy-enum) [toLast](qdatawidgetmapper.html#toLast)()和[setCurrentIndex](qdatawidgetmapper.html#currentIndex-prop)( ) 。 ``` QDataWidgetMapper.toLast (self) ``` 這種方法也是一個Qt槽與C + +的簽名`void toLast()`。 填充部件與模型的最后一行數據,如果方向是水平的(默認值) ,否則從最后一列的數據。 電話[setCurrentIndex](qdatawidgetmapper.html#currentIndex-prop)(內部) 。 **See also** [toFirst](qdatawidgetmapper.html#toFirst)()和[setCurrentIndex](qdatawidgetmapper.html#currentIndex-prop)( ) 。 ``` QDataWidgetMapper.toNext (self) ``` 這種方法也是一個Qt槽與C + +的簽名`void toNext()`。 填充部件與模型的下一行數據,如果方向是水平的(默認值) ,否則與下一列的數據。 電話[setCurrentIndex](qdatawidgetmapper.html#currentIndex-prop)(內部) 。什么都不做,如果有在模型中沒有下一行。 **See also** [toPrevious](qdatawidgetmapper.html#toPrevious)()和[setCurrentIndex](qdatawidgetmapper.html#currentIndex-prop)( ) 。 ``` QDataWidgetMapper.toPrevious (self) ``` 這種方法也是一個Qt槽與C + +的簽名`void toPrevious()`。 填充部件與模型的上一行數據,如果方向是水平的(默認值) ,否則由前一列的數據。 電話[setCurrentIndex](qdatawidgetmapper.html#currentIndex-prop)(內部) 。什么都不做,如果有在模型中沒有前一行。 **See also** [toNext](qdatawidgetmapper.html#toNext)()和[setCurrentIndex](qdatawidgetmapper.html#currentIndex-prop)( ) 。 * * * ## Qt Signal Documentation ``` void currentIndexChanged (int) ``` 這是該信號的默認超載。 這個信號被發射后,目前指數已經改變,所有的部件都填充了新的數據。_index_為新的當前索引。 **See also** [currentIndex](qdatawidgetmapper.html#currentIndex-prop)()和[setCurrentIndex](qdatawidgetmapper.html#currentIndex-prop)( ) 。
                  <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>

                              哎呀哎呀视频在线观看