<areahref="class_qt_mvvm_1_1_quick_presenter.html"title="The IPresenter implementation for the quick module. "alt="QtMvvm::QuickPresenter"shape="rect"coords="0,56,164,80"/>
<areahref="class_qt_mvvm_1_1_widgets_presenter.html"title="The IPresenter implementation for the widgets module. "alt="QtMvvm::WidgetsPresenter"shape="rect"coords="174,56,338,80"/>
<trclass="memdesc:a6bf902cf14d45c44fdcf78743d4e71a7"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Called to present a viewmodel. <ahref="#a6bf902cf14d45c44fdcf78743d4e71a7">More...</a><br/></td></tr>
<trclass="memdesc:a6e2921a23d4a8513a80526141f79b4d1"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Called to present a dialog via a message config. <ahref="#a6e2921a23d4a8513a80526141f79b4d1">More...</a><br/></td></tr>
<divclass="textblock"><p>The interface for a GUI view presenter. </p>
<p>This class is what you need to implement if you want to create your own GUI frontend for mvvm. Once you created your custom presenter class, register it as service before calling <aclass="el"href="class_qt_mvvm_1_1_core_app.html#afb4cd9046e73ed2bca0884c7d0032470"title="Boots up the app and starts the mvvm presenting. ">CoreApp::bootApp()</a> (Or entering the eventloop, in case of automatic startup, like with <aclass="el"href="coreapp_8h.html#aab7ff1f0090a9c98ecb7863f0d4c8af5"title="Registers you custom CoreApp class as CoreApp to be used. ">QTMVVM_REGISTER_CORE_APP</a>)</p>
<p>To register it, it is recommended to use a startup hook like this: </p><divclass="fragment"><divclass="line"><spanclass="keywordtype">void</span> myPresenterInit()</div><divclass="line">{</div><divclass="line"><aclass="code"href="class_qt_mvvm_1_1_service_registry.html#aabda69c79dc04cebfd2ebaea25e9ee62">QtMvvm::ServiceRegistry::instance</a>()-><aclass="code"href="class_qt_mvvm_1_1_service_registry.html#ab683dc8ccbb0e0198f0d5664b1f1f9ca">registerInterface</a><<aclass="code"href="class_qt_mvvm_1_1_i_presenter.html">QtMvvm::IPresenter</a>, MyPresenter>();</div><divclass="line">}</div><divclass="line">Q_COREAPP_STARTUP_FUNCTION(myPresenterInit)</div></div><!-- fragment --><dlclass="section see"><dt>See also</dt><dd><aclass="el"href="ipresenter_8h.html#ace4560167ef93b1f5d79f1b17ec701c7"title="The IID of the QtMvvm::IPresenter class. ">QtMvvm_IPresenterIid</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="ipresenter_8h_source.html#l00036">36</a> of file <aclass="el"href="ipresenter_8h_source.html">ipresenter.h</a>.</p>
</div><h2class="groupheader">Member Function Documentation</h2>
<tr><tdclass="paramname">viewModel</td><td>The <aclass="el"href="class_qt_mvvm_1_1_view_model.html"title="The base class for all viewmodels. ">ViewModel</a> to be presenter </td></tr>
<tr><tdclass="paramname">params</td><td>Additional parameters for the viemodel initialization </td></tr>
<tr><tdclass="paramname">parent</td><td>An optional parent for the viewmodels view </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="el"href="class_qt_mvvm_1_1_presenter_exception.html"title="An exception to be thrown from the presenter if presenting fails. ">PresenterException</a></td><td>When presenting fails for whatever reason</td></tr>
</table>
</dd>
</dl>
<p>This method should:</p>
<oltype="1">
<li>Find and create a view for the viewmodel</li>
<li>Use the view of the parent viewModel to make the new view a child of that parent view</li>
<li>Make the viewmodel a child of the view (via <aclass="elRef"target="_blank"doxygen="/home/sky/Qt/Docs/Qt-5.11.1/qtcore/qtcore.tags:https://doc.qt.io/qt-5/"href="https://doc.qt.io/qt-5/qobject.html#setParent">QObject::setParent</a>)</li>
<li>Call the viewmodels <aclass="el"href="class_qt_mvvm_1_1_view_model.html#aed696c49a28b9615d3433c6a27006c70"title="Called by the presenter to initialize the viewmodel. ">ViewModel::onInit</a> method with the given parameters</li>
<li>Find a presentation method for the view (based on the view/viewmodel and/or parent)</li>
<li>Show the view to the user</li>
</ol>
<p>If this method returns it is assumed the presentation was successful. If you throw the exception, presenting has failed, and the app will automatically destroy the viewmodel and handle cleanups and results.</p>
<dlclass="section note"><dt>Note</dt><dd>If you need to present asynchronous, then you need to perform this step yourself in case the asynchronous presentation failed.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_i_presenter.html#a6e2921a23d4a8513a80526141f79b4d1"title="Called to present a dialog via a message config. ">IPresenter::showDialog</a></dd></dl>
<p>Implemented in <aclass="el"href="class_qt_mvvm_1_1_widgets_presenter.html#a4f4d51ec8d0dcfa190ee813937aa0166">QtMvvm::WidgetsPresenter</a>, and <aclass="el"href="class_qt_mvvm_1_1_quick_presenter.html#a48a41fa588214f7b8a1f2974ae4f541e">QtMvvm::QuickPresenter</a>.</p>
<p>Called to present a dialog via a message config. </p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">config</td><td>The configuration for the dialog to be shown </td></tr>
<tr><tdclass="paramname">result</td><td>A reference to the object to report results to </td></tr>
</table>
</dd>
</dl>
<dlclass="exception"><dt>Exceptions</dt><dd>
<tableclass="exception">
<tr><tdclass="paramname"><aclass="el"href="class_qt_mvvm_1_1_presenter_exception.html"title="An exception to be thrown from the presenter if presenting fails. ">PresenterException</a></td><td>When presenting fails for whatever reason</td></tr>
</table>
</dd>
</dl>
<p>This method should create a simple dialog based of the configuration passed to it. Read the <aclass="el"href="class_qt_mvvm_1_1_message_config.html"title="A configuration for a simple dialog to be shown from the core code. ">MessageConfig</a> for more details on the parameters. The <aclass="el"href="class_qt_mvvm_1_1_message_config.html#a8ddd0717a5f8a07f520df25743ded0da"title="The general type of dialog to be shown. ">MessageConfig::type</a> and <aclass="el"href="class_qt_mvvm_1_1_message_config.html#aa9f8a83b2ce22d09daf24aad158d7974"title="A subtype for the dialog to specify what exactly it should show. ">MessageConfig::subType</a> properties are used to determine the kind of dialog to be shown. The other properties are used to configure the dialog.</p>
<p>The result is a reference to a result object to report the result value and the pressed button to. The result is owned by the caller, you must never delete it. Use the special "GUI methods" to report the result and configure a close target.</p>
<p>If this method returns it is assumed the presentation was successful. If you throw the exception, presenting has failed, and the app will automatically complete the message result with the <aclass="el"href="class_qt_mvvm_1_1_message_config.html#ad6b7b271e558619f15c5eb9a3cf78fb8a83a48e3acfda22ae83280136ed2f6751"title="Equivalent to QMessageBox::NoButton. ">MessageConfig::NoButton</a> constant.</p>
<dlclass="section note"><dt>Note</dt><dd>If you need to present asynchronous, then you need to perform this step yourself in case the asynchronous presentation failed.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_qt_mvvm_1_1_i_presenter.html#a6bf902cf14d45c44fdcf78743d4e71a7"title="Called to present a viewmodel. ">IPresenter::present</a>, <aclass="el"href="class_qt_mvvm_1_1_message_config.html"title="A configuration for a simple dialog to be shown from the core code. ">MessageConfig</a>, <aclass="el"href="class_qt_mvvm_1_1_message_result.html"title="A result watcher to get the result once a dialog has finished. ">MessageResult</a>, <aclass="el"href="class_qt_mvvm_1_1_message_result.html#ac43f7ca1c7e3b10e6477c2a5d92348af"title="Completes the dialog and tells the result that it is finished. ">MessageResult::complete</a>, <aclass="el"href="class_qt_mvvm_1_1_message_result.html#adf611c77583607f2ea90764871ccd3cd"title="Sets an object and a method to be called to close the dialog. ">MessageResult::setCloseTarget</a></dd></dl>
<p>Implemented in <aclass="el"href="class_qt_mvvm_1_1_widgets_presenter.html#a4766ec05cd6999ee16505d472e48adf9">QtMvvm::WidgetsPresenter</a>, and <aclass="el"href="class_qt_mvvm_1_1_quick_presenter.html#afafe3383676b831754482c368fe2b8cc">QtMvvm::QuickPresenter</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>