码迷,mamicode.com
首页 > 编程语言 > 详细

Qt中使用python--Hello Python!

时间:2017-12-04 13:06:20      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:console   title   play   har   技术分享   string   ring   ram   border   

step1:install Python (version 2.7 or higher);

step2:The configuration is as follows:

            1.create qt console application

            2.windows:在.pro工程文件里添加python版本的include和lib路径:

                        INCLUDEPATH +=C:/Python27/include

                LIBS +=C:/Python27/libs/python27.lib
         linux:在.pro工程文件里添加python版本的include和lib路径:
               INCLUDEPATH += –I C:\Python27\include
                LIBS += –L C:\Python27\libs –lpython27
        3.main.cpp

                       #include <QCoreApplication>

               #include <Python.h>

             int main(int argc, char *argv[])
          {
               QCoreApplication a(argc, argv);
               Py_SetProgramName(argv[0]);
               Py_Initialize();
               PyRun_SimpleString("print ‘Hello Python!‘\n");
               Py_Finalize();
               return a.exec();
          }   

技术分享图片技术分享图片技术分享图片


Qt中使用python--Hello Python!

标签:console   title   play   har   技术分享   string   ring   ram   border   

原文地址:http://www.cnblogs.com/kaikai-king/p/7976339.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!