• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            Cpper
            C/C++高級工程師 Android高級軟件工程師 IT集成工程師 音頻工程師 熟悉c,c++,java,c#,py,js,asp等多種語言 程序猿

            qint64 get_size()
            {   
                QString link 
            = url->text();
                std::cout
            <<qPrintable(link)<<std::endl;
                QNetworkAccessManager manager;
                QEventLoop loop;
                QNetworkReply 
            *reply = manager.head(QNetworkRequest(link));
                QObject::connect(reply,SIGNAL(finished()), 
            &loop, SLOT(quit()), Qt::DirectConnection);
                loop.exec();
                QVariant var 
            = reply->header(QNetworkRequest::ContentLengthHeader);
                delete reply;
                qint64 size 
            = var.toLongLong();
                std::cout
            <<size<<std::endl;
                
            return size;
            }
            posted @ 2013-01-27 22:31 ccsdu2009 閱讀(2842) | 評論 (0)編輯 收藏
             
            class uWidget : public QWidget
            {
            public:
                uWidget()
                {
                    QCompleter 
            * completer = new QCompleter(this);
                    QFileSystemModel 
            * model = new QFileSystemModel(completer);
                    model
            ->setFilter(QDir::Dirs | QDir::Drives | QDir::AllDirs);// | QDir::NoDotAndDotDot);
                    model->setRootPath(tr("D:"));
                    completer
            ->setModel(model);

                    QHBoxLayout
            * layout = new QHBoxLayout(this);
                    QPushButton
            * button = new QPushButton("Click");
                    QLineEdit
            * edit = new QLineEdit();
                    layout
            ->addWidget(button);
                    layout
            ->addWidget(edit);
                    edit
            ->setCompleter(completer);
                }
            };

            posted @ 2013-01-26 18:07 ccsdu2009 閱讀(2507) | 評論 (0)編輯 收藏
             
            具體可參見qt下的例子-webkit\previewer
            通過webview->setHtml(string);即可加載顯示網頁信息
            另外通過QWebFrame* frame = webview->page()->mainFrame();即獲取當前網頁源碼

            感覺QWebView使用很方便的,只不過QWebkit.dll大小為11.5m太夸張了.
            posted @ 2013-01-21 20:04 ccsdu2009 閱讀(5565) | 評論 (1)編輯 收藏
             
                public static String load(String name)
                {
                    File file 
            = new File(name);
                    String buffer 
            = new String();
                    
            if(!file.exists())
                    { 
                        System.out.println(
            "can't find " + name);
                    }

                    
            try 
                    {
                        BufferedReader reader 
            = new BufferedReader(new FileReader(file));
                        String line;
                        
            while((line = reader.readLine()) != null
                        {
                            buffer 
            += line;
                        }
                        reader.close();
                    } 
                    
            catch (IOException e) 
                    {
                        e.getStackTrace();
                    }
                    
            return buffer;
                }   
            posted @ 2013-01-19 22:33 ccsdu2009| 編輯 收藏
             
            #include <QApplication>
            #include 
            <QMessageBox>
            #include 
            <QtUiTools/QtUiTools>
            #include 
            <iostream>

            int main(int argc, char* argv[])
            {
                QApplication app(argc, argv);

                QUiLoader loader;
                QFile file(
            "ui.ui");
                QWidget
            * ui = loader.load(&file);
                
            if(ui)
                {
                    
            foreach(QString name,loader.availableWidgets())
                         std::cout
            <<qPrintable(name)<<std::endl;
                    ui
            ->show();
                }
                
            else
                {
                    QMessageBox::information(NULL,
            "Error","Load ui script failed");
                }
                
            return app.exec();
            }

            有時候動態載入控件還是很有必要的
            posted @ 2013-01-17 19:25 ccsdu2009 閱讀(1384) | 評論 (0)編輯 收藏
             
            python代碼二段:

            call.py
            def test():
                
            print 'hello world'


            def add(a,b):
                
            return a + b

            api.py
            import io

            def load_test():
                fp 
            = open('call.py','r')
                buffer 
            = ''
                
            if fp:
                    buffer 
            = fp.read()
                fp.close()
                
            return buffer

            cpp代碼:
            #include <stdio.h>
            #include 
            <stdlib.h>
            #include 
            <Python.h>

            int main(int argc, char *argv[])
            {
                Py_Initialize();  
                
            if(!Py_IsInitialized())   
                {  
                    
            return -1;  
                }  
                
                PyRun_SimpleString(
            "import sys");
                PyRun_SimpleString(
            "sys.path.append('./')");
                PyObject
            * pName;
                PyObject
            * pModule;
                PyObject
            * pDict;
                PyObject
            * pFunc;
                
                pName 
            = PyString_FromString("api");
                pModule 
            = PyImport_Import(pName);
                
            if(!pModule)
                {
                    printf(
            "can't find call.py");
                    getchar();
                    
            return -1;
                }
                
                pDict 
            = PyModule_GetDict(pModule);
                
            if(!pDict)
                {
                    
            return -1;
                }
                
                {
                    pFunc 
            = PyDict_GetItemString(pDict,"load_test");
                    
            if(!pFunc || !PyCallable_Check(pFunc))
                    {
                        printf(
            "can't find function [test]");
                        getchar();
                        
            return -1;
                    }
                    
                    PyObject 
            *pFn = PyObject_CallObject(pFunc,0);
                    
            char* buffer = PyString_AsString(pFn);
                    printf(
            "%s\n",buffer);
                    
                    PyObject
            * o = Py_CompileString(buffer,"none",Py_file_input);
                    PyObject
            * m = PyImport_ExecCodeModule("a.a",o);
                    PyObject
            * d = PyModule_GetDict(m);
                    pFunc 
            = PyDict_GetItemString(d,"add");
                    
            if(!pFunc || !PyCallable_Check(pFunc))
                    {
                        printf(
            "can't find function [add]");
                        getchar();
                        
            return -1;
                    }
                    
                    PyObject
            * args = PyTuple_New(2);
                    PyTuple_SetItem(args,
            0,Py_BuildValue("l",3));
                    PyTuple_SetItem(args,
            1,Py_BuildValue("l",4));
                    PyObject 
            *pAdded = PyObject_CallObject(pFunc,args);
                    
            int ret = PyInt_AsLong(pAdded);  
                    printf(
            "add value:%d\n",ret);    
                }
             
                Py_Finalize();    
                system(
            "PAUSE");    
                
            return 0;
            }

            這段代碼和上一篇有點區別
            主要區別是從從內存載入python模塊然后調用函數
            主要部分是這塊:
                    PyObject* o = Py_CompileString(buffer,"none",Py_file_input);
                    PyObject* m = PyImport_ExecCodeModule("a.a",o);
                    PyObject* d = PyModule_GetDict(m);
            buffer是python源碼字符串

            在python2.7中執行正常
            posted @ 2013-01-15 21:39 ccsdu2009 閱讀(2734) | 評論 (0)編輯 收藏
             
            先上python代碼:
            # call.py

            def test():
                print 
            'hello world'


            def add(a,b):
                
            return a + b

            再上c代碼
            #include <stdio.h>
            #include 
            <stdlib.h>
            #include 
            <Python.h>

            int main(int argc, char *argv[])
            {
                Py_Initialize();  
                
            if(!Py_IsInitialized())   
                {  
                    
            return -1;  
                }  
                
                PyRun_SimpleString(
            "import sys");
                PyRun_SimpleString(
            "sys.path.append('./')");
                PyObject
            * pName;
                PyObject
            * pModule;
                PyObject
            * pDict;
                PyObject
            * pFunc;
                
                pName 
            = PyString_FromString("call");
                pModule 
            = PyImport_Import(pName);
                
            if(!pModule)
                {
                    printf(
            "can't find call.py");
                    getchar();
                    
            return -1;
                }
                
                pDict 
            = PyModule_GetDict(pModule);
                
            if(!pDict)
                {
                    
            return -1;
                }
                
                {
                    pFunc 
            = PyDict_GetItemString(pDict,"test");
                    
            if(!pFunc || !PyCallable_Check(pFunc))
                    {
                        printf(
            "can't find function [test]");
                        getchar();
                        
            return -1;
                    }
                    
                    PyObject_CallObject(pFunc,
            0);
                }
                
                {
                    pFunc 
            = PyDict_GetItemString(pDict,"add");
                    
            if(!pFunc || !PyCallable_Check(pFunc))
                    {
                        printf(
            "can't find function [test]");
                        getchar();
                        
            return -1;
                    }
                    
                    PyObject
            * args = PyTuple_New(2);
                    PyTuple_SetItem(args,
            0,Py_BuildValue("l",3));
                    PyTuple_SetItem(args,
            1,Py_BuildValue("l",4));
                    PyObject 
            *pAdded = PyObject_CallObject(pFunc,args);
                    
            int ret = PyInt_AsLong(pAdded);  
                    printf(
            "add value:%d\n",ret);
                    Py_DECREF(args);
                }    
                
                Py_DECREF(pName);
                Py_DECREF(pDict);
                Py_DECREF(pModule);
                Py_Finalize();    
                system(
            "PAUSE");    
                
            return 0;
            }
            就不做解釋了
            不過如何從字符串中載入模塊?
            posted @ 2013-01-14 21:44 ccsdu2009 閱讀(3866) | 評論 (0)編輯 收藏
             
            #include <QApplication> 
            #include 
            <QStateMachine> 
            #include 
            <QPushButton>
            #include 
            <QTextEdit>
            #include 
            <QHBoxLayout>
            #include 
            <QVBoxLayout>
            #include 
            <QSpacerItem>
            #include 
            <QSignalTransition> 
            #include 
            <QPropertyAnimation> 

            int main(int argc,char **argv)
            {  
                QApplication app(argc,argv);  

                QWidget
            * panel = new QWidget;  
                panel
            ->resize(320,360);  

                QVBoxLayout
            * layout = new QVBoxLayout();
                panel
            ->setLayout(layout);
                               
                QPushButton
            * button = new QPushButton("Click");
                QSpacerItem
            * spacer = new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Minimum);
                QHBoxLayout
            * hlayout = new QHBoxLayout();
                layout
            ->addLayout(hlayout);
                hlayout
            ->addItem(spacer);
                hlayout
            ->addWidget(button);

                QTextEdit
            * edit1 = new QTextEdit();
                edit1
            ->setGeometry(QRect(10,50,300,300));
                QTextEdit
            * edit2 = new QTextEdit();
                edit2
            ->setGeometry(QRect(10,300,300,0));
                layout
            ->addWidget(edit1);
                layout
            ->addWidget(edit2);

                QStateMachine
            * machine = new QStateMachine;
                
                QState
            * state1 = new QState(machine);      
                state1
            ->assignProperty(edit1,"geometry",QRect(10,50,300,300));
                state1
            ->assignProperty(edit2,"geometry",QRect(10,300,300,0));
             
                QState
            * state2 = new QState(machine);  
                state2
            ->assignProperty(edit1,"geometry",QRect(10,50,300,0)); 
                state2
            ->assignProperty(edit2,"geometry",QRect(10,50,300,300));
                            
                machine
            ->setInitialState(state1);  

                QPropertyAnimation
            * ani1 = new QPropertyAnimation(edit1,"geometry"); 
                ani1
            ->setDuration(2000);    
                ani1
            ->setEasingCurve(QEasingCurve::OutBounce);    
                
                QPropertyAnimation
            * ani2 = new QPropertyAnimation(edit2,"geometry"); 
                ani2
            ->setDuration(2000);    
                ani2
            ->setEasingCurve(QEasingCurve::InOutExpo);

                QSignalTransition
            * transition1 = state1->addTransition(button,SIGNAL(clicked()),state2);
                QSignalTransition
            * transition2 = state2->addTransition(button,SIGNAL(clicked()),state1); 

                transition1
            ->addAnimation(ani1);   
                transition1
            ->addAnimation(ani2); 
                transition2
            ->addAnimation(ani1); 
                transition2
            ->addAnimation(ani2); 
                
                machine
            ->start();   
                panel
            ->show();  
                
                
            return app.exec();  
            }
            posted @ 2013-01-02 17:35 ccsdu2009 閱讀(2149) | 評論 (1)編輯 收藏
             
            有時候需要從QUrl中取出本地文件名
            代碼如下:
            QFileInfo info(url.toLocalFile());
            QString filename 
            = info.absoluteFilePath();
            posted @ 2013-01-01 12:15 ccsdu2009 閱讀(789) | 評論 (0)編輯 收藏
             
            libavformat
            libavcodec
            libavutil
            posted @ 2012-12-29 21:33 ccsdu2009 閱讀(905) | 評論 (0)編輯 收藏
            僅列出標題
            共38頁: First 10 11 12 13 14 15 16 17 18 Last 
             
            久久精品人成免费| 久久精品无码一区二区日韩AV| 精品久久久久久无码不卡| 久久久久国产精品人妻| 国产一区二区精品久久| 国内精品久久久久久久亚洲| 中文字幕热久久久久久久| 久久最近最新中文字幕大全 | 青青久久精品国产免费看| 久久亚洲AV成人无码软件| 亚洲国产成人久久精品动漫| 亚洲精品国产自在久久| 99久久人妻无码精品系列 | 国产成人久久久精品二区三区| 麻豆久久| 久久播电影网| 91精品国产高清久久久久久io | 久久丫精品国产亚洲av| 久久久久久久综合日本| 久久久国产精品福利免费| 亚洲va久久久噜噜噜久久| 久久午夜免费视频| 久久97久久97精品免视看秋霞| 高清免费久久午夜精品| 中文字幕久久久久人妻| 中文成人久久久久影院免费观看| 亚洲国产精品久久久久网站 | 精品久久久久久无码中文字幕| 久久99精品久久久久婷婷| 亚洲综合日韩久久成人AV| 亚洲国产成人久久精品99 | 精品国产一区二区三区久久久狼| 久久婷婷是五月综合色狠狠| 久久久久婷婷| 热久久国产欧美一区二区精品| 国产福利电影一区二区三区久久老子无码午夜伦不 | 精品午夜久久福利大片| 久久99国产精品一区二区| 亚洲国产精品久久久久久| 国内精品久久久久久不卡影院| 久久99精品免费一区二区|