{"id":197374,"date":"2013-10-13T21:31:03","date_gmt":"2013-10-13T17:31:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=197374"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=197374","title":{"rendered":"<span class=\"post_title\">\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f C++ \u0432 QML<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h4><b>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/b><\/h4>\n<p>  \u042f\u0437\u044b\u043a QML \u0434\u043b\u044f Qt Quick \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 c \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u0438\u0435 \u0432\u0435\u0449\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0447\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432. \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435 \u0432\u0441\u0451 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043b\u0438 \u043d\u0435 \u0432\u0441\u0451 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 QML, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438:<\/p>\n<ul>\n<li>\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u0437\u0432\u043d\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f QML\/Javascript<\/li>\n<li>\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0433\u0434\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438<\/li>\n<li>\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u043b\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043d\u0435 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432 JavaScript<\/li>\n<\/ul>\n<p>  \u041a\u0430\u043a \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438, Qt \u043b\u0435\u0433\u043a\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 C++ \u043a\u043e\u0434 \u0434\u043b\u044f QML. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0435, \u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0434\u0435\u043b\u0430\u044e\u0449\u0435\u0435 \u044d\u0442\u043e. \u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0434\u043b\u044f Qt 5 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b Qt Quick, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0412\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c Qt 5.1.0.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4><b>\u041e\u0431\u0437\u043e\u0440<\/b><\/h4>\n<p>  \u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0448\u0430\u0433\u0438, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0438\u043f C++, \u0441 \u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438, \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0441\u0438\u0433\u043d\u0430\u043b\u0430\u043c\u0438 \u0438 \u0441\u043b\u043e\u0442\u0430\u043c\u0438, \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044e QML:  <\/p>\n<ul>\n<li>\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0442 <i>QObject<\/i><\/li>\n<li>\u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 <b>Q_OBJECT<\/b> \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432, \u0441\u043b\u043e\u0442\u043e\u0432 \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043c\u0435\u0442\u0430\u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b Qt<\/li>\n<li>\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0430\u043a\u0440\u043e\u0441 <b>Q_PROPERTY<\/b><\/li>\n<li>\u0432\u044b\u0437\u043e\u0432 <i>qmlRegisterType()<\/i> \u0432 C++ \u043a\u043e\u0434\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u0430 \u0432 Qt Quick \u0434\u0432\u0438\u0436\u043a\u0435<\/li>\n<\/ul>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Qt <a href=\"http:\/\/qt-project.org\/doc\/qt-5.1\/qtqml\/qtqml-cppintegration-exposecppattributes.html\">\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 C++ \u0434\u043b\u044f QML<\/a> \u0438 \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 <a href=\"http:\/\/qt-project.org\/doc\/qt-5.1\/qtqml\/qtqml-modules-cppplugins.html\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 C++ \u0434\u043b\u044f QML<\/a>.<\/p>\n<h4><b>\u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 SSH \u043a\u043b\u044e\u0447\u0435\u0439<\/b><\/h4>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0443 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e\/\u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e SSH \u043a\u043b\u044e\u0447\u0435\u0439, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e GUI. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0437\u0430\u0442\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 ssh-keygen \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u044b \u043a\u043b\u044e\u0447\u0435\u0439.<\/p>\n<p>  \u041c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043d\u043e\u0432\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f Qt Quick, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043e \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e, \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u044b\u0442\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c qmlscene \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c QML. \u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u043d\u0438\u0436\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/c16\/ced\/480\/c16ced480e658d2ae2021bc54741b648.png\"\/><\/p>\n<p>  \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0442\u0438\u043f\u0435 \u043a\u043b\u044e\u0447\u0430, \u0438\u043c\u0435\u043d\u0438 \u0444\u0430\u0439\u043b\u0430 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0438, \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e, \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0444\u0440\u0430\u0437\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0430.<\/p>\n<h4><b>C++ \u043a\u043b\u0430\u0441\u0441<\/b><\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u043c\u0435\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u044e\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 QML, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430 C++ (\u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0446\u0435\u043b\u044c\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f).<\/p>\n<p>  \u0421\u043f\u0435\u0440\u0432\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043a\u043b\u0430\u0441\u0441, \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u044e\u0447\u0430 (\u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d \u043a\u0430\u043a \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <i>KeyGenerator<\/i> \u0432 QML). \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <i>KeyGenerator.h<\/i>:<\/p>\n<pre><code class=\"cpp\">#ifndef KEYGENERATOR_H #define KEYGENERATOR_H  #include &lt;QObject&gt; #include &lt;QString&gt; #include &lt;QStringList&gt;  \/\/ Simple QML object to generate SSH key pairs by calling ssh-keygen.  class KeyGenerator : public QObject {     Q_OBJECT     Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)     Q_PROPERTY(QStringList types READ types NOTIFY typesChanged)     Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged)     Q_PROPERTY(QString passphrase READ filename WRITE setPassphrase NOTIFY passphraseChanged)  public:     KeyGenerator();     ~KeyGenerator();      QString type();     void setType(const QString &t);      QStringList types();      QString filename();     void setFilename(const QString &f);      QString passphrase();     void setPassphrase(const QString &p);  public slots:     void generateKey();  signals:     void typeChanged();     void typesChanged();     void filenameChanged();     void passphraseChanged();     void keyGenerated(bool success);  private:     QString _type;     QString _filename;     QString _passphrase;     QStringList _types; }; #endif <\/code><\/pre>\n<p>  \u041d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u043e\u0442 <i>QObject<\/i>. \u041c\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0438 \u0432\u0441\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u044b, \u043c\u0435\u0442\u043e\u0434\u044b \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u0430\u043c\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u043c\u0435\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043a\u043b\u044e\u0447\u0430, \u0441\u043f\u0438\u0441\u043a\u0430 \u0432\u0441\u0435\u0445 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 SSH \u043a\u043b\u044e\u0447\u0435\u0439, \u0438\u043c\u0435\u043d\u0438 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0444\u0440\u0430\u0437\u044b. \u0422\u0438\u043f \u043a\u043b\u044e\u0447\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u043d \u0441\u0442\u0440\u043e\u043a\u043e\u0439. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435\u043c, \u043d\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0431\u044b\u043b \u0431\u044b \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c.<\/p>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438, \u043d\u043e\u0432\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u0430\u043a\u0440\u043e\u0441\u0430 <b>Q_PROPERTY<\/b> \u0432 Qt 5.1.0 \u2014 \u044d\u0442\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <b>MEMBER<\/b>. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u044f\u0432\u043b\u044f\u044e\u0449\u0443\u044e\u0441\u044f \u0447\u043b\u0435\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u0430 \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443, \u0431\u0435\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438. \u042d\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u0443\u0442 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u0434\u043b\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432. \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043e\u0434\u0438\u043d \u0441\u043b\u043e\u0442 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <i>generateKey()<\/i>. \u0412\u0441\u0451 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0434\u043b\u044f QML. \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u0438\u0434\u0438\u043c\u044b\u043c \u0434\u043b\u044f QML, \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u044b \u0431\u044b\u043b\u043e \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u043a\u0430\u043a <b>Q_INVOCABLE<\/b>. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>generateKey()<\/i> \u0441\u043b\u043e\u0442\u043e\u043c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u043d\u043e \u043e\u043d \u0441 \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c.<\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435, \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043d\u0430\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0435 \u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<h4><b>C++ \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/b><\/h4>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 <i>KeyGenerator.cpp<\/i>. \u0412\u043e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">#include &lt;QFile&gt; #include &lt;QProcess&gt; #include &quot;KeyGenerator.h&quot;  KeyGenerator::KeyGenerator()     : _type(&quot;rsa&quot;), _types{&quot;dsa&quot;, &quot;ecdsa&quot;, &quot;rsa&quot;, &quot;rsa1&quot;} { }  KeyGenerator::~KeyGenerator() { }  QString KeyGenerator::type() {     return _type; }  void KeyGenerator::setType(const QString &t) {     \/\/ Check for valid type.     if (!_types.contains(t))         return;      if (t != _type) {         _type = t;         emit typeChanged();     } }  QStringList KeyGenerator::types() {     return _types; }  QString KeyGenerator::filename() {     return _filename; }  void KeyGenerator::setFilename(const QString &f) {     if (f != _filename) {         _filename = f;         emit filenameChanged();     } }  QString KeyGenerator::passphrase() {     return _passphrase; }  void KeyGenerator::setPassphrase(const QString &p) {     if (p != _passphrase) {         _passphrase = p;         emit passphraseChanged();     } }  void KeyGenerator::generateKey() {     \/\/ Sanity check on arguments     if (_type.isEmpty() or _filename.isEmpty() or         (_passphrase.length() &gt; 0 and _passphrase.length() &lt; 5)) {         emit keyGenerated(false);         return;     }      \/\/ Remove key file if it already exists     if (QFile::exists(_filename)) {         QFile::remove(_filename);     }      \/\/ Execute ssh-keygen -t type -N passphrase -f keyfileq     QProcess *proc = new QProcess;     QString prog = &quot;ssh-keygen&quot;;     QStringList args{&quot;-t&quot;, _type, &quot;-N&quot;, _passphrase, &quot;-f&quot;, _filename};     proc-&gt;start(prog, args);     proc-&gt;waitForFinished();     emit keyGenerated(proc-&gt;exitCode() == 0);     delete proc; } <\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0430. \u0414\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c C++11 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0447\u043b\u0435\u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 _types, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <i>QStringList<\/i>. \u0414\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442, \u043d\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u0438 \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <i>type()<\/i> \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0440\u0430\u0449\u0430\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0443\u044e\u0449\u0435\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0447\u043b\u0435\u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u0430. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0437\u0430\u0431\u043e\u0442\u044f\u0441\u044c \u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435, \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0438, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a, \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u0433\u043d\u0430\u043b. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u044b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 MOC, \u043a\u0430\u043a \u0438 \u0432\u0441\u0435\u0433\u0434\u0430, \u043d\u0435 \u043d\u0443\u0436\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  \u0422\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0438\u043c \u043d\u0435 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0435\u0441\u0442\u044c \u0441\u043b\u043e\u0442 <i>generateKey()<\/i>. \u041e\u043d \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 <i>QProcess<\/i> \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u043d\u0435\u0448\u043d\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b ssh-keygen. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0438 \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u043e, \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f ssh-keygen. \u041a\u043e\u0433\u0434\u0430 \u044d\u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f, \u0438\u0437\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0438\u0433\u043d\u0430\u043b, \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0441 \u0442\u0438\u043f\u043e\u043c boolean, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0431\u044b\u043b\u0430 \u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0438\u043b\u0438 \u043d\u0435\u0442.<\/p>\n<h4><b>\u041a\u043e\u0434 QML<\/b><\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 QML \u043a\u043e\u0434 \u0432 <i>main.qml<\/i>:<\/p>\n<pre><code class=\"cpp\">\/\/ SSH key generator UI  import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 import QtQuick.Dialogs 1.0 import com.ics.demo 1.0  ApplicationWindow {     title: qsTr(&quot;SSH Key Generator&quot;)      statusBar: StatusBar {     RowLayout {         Label {             id: status             }         }     }      width: 369     height: 166      ColumnLayout {         x: 10         y: 10          \/\/ Key type         RowLayout {             Label {                 text: qsTr(&quot;Key type:&quot;)             }             ComboBox {                 id: combobox                 Layout.fillWidth: true                 model: keygen.types                 currentIndex: 2             }         }          \/\/ Filename         RowLayout {             Label {                 text: qsTr(&quot;Filename:&quot;)             }             TextField {                 id: filename                 implicitWidth: 200                 onTextChanged: updateStatusBar()             }             Button {                 text: qsTr(&quot;&Browse...&quot;)                 onClicked: filedialog.visible = true             }         }          \/\/ Passphrase         RowLayout {             Label {                 text: qsTr(&quot;Pass phrase:&quot;)             }             TextField {                 id: passphrase                 Layout.fillWidth: true                 echoMode: TextInput.Password                 onTextChanged: updateStatusBar()             }          }          \/\/ Confirm Passphrase         RowLayout {             Label {                 text: qsTr(&quot;Confirm pass phrase:&quot;)             }             TextField {                 id: confirm                 Layout.fillWidth: true                 echoMode: TextInput.Password                 onTextChanged: updateStatusBar()             }         }          \/\/ Buttons: Generate, Quit         RowLayout {             Button {                 id: generate                 text: qsTr(&quot;&Generate&quot;)                 onClicked: keygen.generateKey()             }             Button {                 text: qsTr(&quot;&Quit&quot;)                 onClicked: Qt.quit()             }         }      }      FileDialog {         id: filedialog         title: qsTr(&quot;Select a file&quot;)         selectMultiple: false         selectFolder: false         nameFilters: [ &quot;All files (*)&quot; ]         selectedNameFilter: &quot;All files (*)&quot;         onAccepted: {             filename.text = fileUrl.toString().replace(&quot;file:\/\/&quot;, &quot;&quot;)         }     }      KeyGenerator {         id: keygen         filename: filename.text         passphrase: passphrase.text         type: combobox.currentText         onKeyGenerated: {             if (success) {                 status.text = qsTr('&lt;font color=&quot;green&quot;&gt;Key generation succeeded.&lt;\/font&gt;')             } else {                 status.text = qsTr('&lt;font color=&quot;red&quot;&gt;Key generation failed&lt;\/font&gt;')             }         }     }      function updateStatusBar() {         if (passphrase.text != confirm.text) {             status.text = qsTr('&lt;font color=&quot;red&quot;&gt;Pass phrase does not match.&lt;\/font&gt;')             generate.enabled = false         } else if (passphrase.text.length &gt; 0 && passphrase.text.length &lt; 5) {             status.text = qsTr('&lt;font color=&quot;red&quot;&gt;Pass phrase too short.&lt;\/font&gt;')             generate.enabled = false         } else if (filename.text == &quot;&quot;) {             status.text = qsTr('&lt;font color=&quot;red&quot;&gt;Enter a filename.&lt;\/font&gt;')             generate.enabled = false         } else {             status.text = &quot;&quot;             generate.enabled = true         }     }      Component.onCompleted: updateStatusBar() } <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u0434 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043e\u0434\u043d\u0430\u043a\u043e, \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0440\u0430\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 GUI. \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u0447\u0442\u043e\u0431\u044b \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c com.ics.demo \u0432\u0435\u0440\u0441\u0438\u0438 1.0. \u0412\u0441\u043a\u043e\u0440\u0435, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0433\u0434\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043c\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 QML \u0442\u0438\u043f <i>KeyGenerator<\/i> \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c \u0438 \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440. \u0418\u043c\u0435\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0435\u0433\u043e C++ \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c, \u043a\u0430\u043a \u043a QML \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0441\u0438\u0433\u043d\u0430\u043b\u0430\u043c\u0438, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0441 <i>onKeyGenerated<\/i>.<\/p>\n<p>  \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445, \u0435\u0441\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0439 (\u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438\u043b\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e). \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c, \u0434\u0435\u043b\u0430\u044f \u0435\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u043c.<\/p>\n<p>  \u041d\u0430\u0448\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u043f\u043e \u0441\u0443\u0442\u0438, \u0432\u0440\u0430\u043f\u043f\u0435\u0440\u043e\u043c, \u0442\u0430\u043a\u0438\u043c \u043a\u0430\u043a <i>qmlscene<\/i>. \u0412\u0441\u0451 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u044d\u0442\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u0442\u0438\u043f, \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0435\u043c\u0443 \u0432 \u0434\u0432\u0438\u0436\u043a\u0435 QML:<\/p>\n<pre><code class=\"cpp\">qmlRegisterType&lt;KeyGenerator&gt;(&quot;com.ics.demo&quot;, 1, 0, &quot;KeyGenerator&quot;); <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 C++ \u0442\u0438\u043f <i>KeyGenerator<\/i> \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u043a\u0430\u043a QML \u0442\u0438\u043f <i>KeyGenerator<\/i>, \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 <i>com.ics.demo<\/i> \u0432\u0435\u0440\u0441\u0438\u0438 1.0, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d.<\/p>\n<p>  \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 QML \u043a\u043e\u0434\u0430 \u0438\u0437 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0412\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 <i>QGuiApplication<\/i> \u0438 <i>QQuickView<\/i>. \u0421\u0435\u0439\u0447\u0430\u0441 \u0436\u0435, \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 Qt Quick \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b, \u0435\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f <i>ApplicationWindow<\/i> \u0438\u043b\u0438 <i>Window<\/i>. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u0443\u0440\u0435\u0437\u0430\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f <i>qmlscene<\/i>, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430.<\/p>\n<p>  \u0412\u043e\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, <i>main.cpp<\/i>:<\/p>\n<pre><code class=\"cpp\">#include &lt;QApplication&gt; #include &lt;QObject&gt; #include &lt;QQmlComponent&gt; #include &lt;QQmlEngine&gt; #include &lt;QQuickWindow&gt; #include &lt;QSurfaceFormat&gt; #include &quot;KeyGenerator.h&quot;  \/\/ Main wrapper program. \/\/ Special handling is needed when using Qt Quick Controls for the top window. \/\/ The code here is based on what qmlscene does.  int main(int argc, char ** argv) {     QApplication app(argc, argv);      \/\/ Register our component type with QML.     qmlRegisterType&lt;KeyGenerator&gt;(&quot;com.ics.demo&quot;, 1, 0, &quot;KeyGenerator&quot;);      int rc = 0;      QQmlEngine engine;     QQmlComponent *component = new QQmlComponent(&engine);      QObject::connect(&engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));      component-&gt;loadUrl(QUrl(&quot;main.qml&quot;));      if (!component-&gt;isReady() ) {         qWarning(&quot;%s&quot;, qPrintable(component-&gt;errorString()));         return -1;     }      QObject *topLevel = component-&gt;create();     QQuickWindow *window = qobject_cast&lt;QQuickWindow *&gt;(topLevel);      QSurfaceFormat surfaceFormat = window-&gt;requestedFormat();     window-&gt;setFormat(surfaceFormat);     window-&gt;show();      rc = app.exec();      delete component;     return rc; } <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 C++, \u0441 QML, \u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 <i>qmlscene<\/i>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e C++ \u043a\u043e\u0434 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0438\u043d\u043a\u043e\u0432\u0430\u043d. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0412\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442\u0435 \u044d\u0442\u043e, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435, \u0447\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d.<\/p>\n<h4><b>\u0412\u044b\u0432\u043e\u0434\u044b<\/b><\/h4>\n<p>  \u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 QML \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043d\u0430 C++ \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0441\u0438\u0433\u043d\u0430\u043b\u044b \u0438 \u0441\u043b\u043e\u0442\u044b. \u0425\u043e\u0442\u044f \u043c\u043d\u043e\u0433\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 QML, C++ \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0438, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 QML \u0432 \u043b\u044e\u0431\u043e\u043c \u043d\u0435 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 <a href=\"ftp:\/\/ftp.ics.com\/pub\/pickup\/qmlc++.zip\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>.   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/197374\/\"> http:\/\/habrahabr.ru\/post\/197374\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h4><b>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/b><\/h4>\n<p>  \u042f\u0437\u044b\u043a QML \u0434\u043b\u044f Qt Quick \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 c \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u0438\u0435 \u0432\u0435\u0449\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0447\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432. \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435 \u0432\u0441\u0451 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043b\u0438 \u043d\u0435 \u0432\u0441\u0451 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 QML, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438:<\/p>\n<ul>\n<li>\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u0437\u0432\u043d\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f QML\/Javascript<\/li>\n<li>\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0433\u0434\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438<\/li>\n<li>\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u043b\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043d\u0435 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432 JavaScript<\/li>\n<\/ul>\n<p>  \u041a\u0430\u043a \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438, Qt \u043b\u0435\u0433\u043a\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 C++ \u043a\u043e\u0434 \u0434\u043b\u044f QML. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0435, \u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0434\u0435\u043b\u0430\u044e\u0449\u0435\u0435 \u044d\u0442\u043e. \u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0434\u043b\u044f Qt 5 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b Qt Quick, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0412\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c Qt 5.1.0.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-197374","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/197374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=197374"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/197374\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=197374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=197374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=197374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}