• <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等多種語言 程序猿

            1.不顯示警告
            只需要加載空回調(diào)函數(shù)即可
            如下:
            Bool cb(TidyDoc tdoc,TidyReportLevel lvl,uint line,uint col,ctmbstr mssg)
            {  
                
            return no;
            }

            tidySetReportFilter(doc,(TidyReportFilter)cb);
            2.顯示節(jié)點(diǎn)文本
                TidyBuffer buf;
                tidyBufInit(
            &buf);
                tidyNodeGetText(doc,body,
            &buf);
                printf(
            "text:%s",buf.bp);
                tidyBufFree(
            &buf);
            posted @ 2012-05-05 16:43 ccsdu2009 閱讀(470) | 評論 (0)編輯 收藏
             
            使用msvc開發(fā)QT插件,不能簡單的使用vc向?qū)гO(shè)置為dll開發(fā),而應(yīng)該使用qmake或者選擇qt的vc插件
            要不然出現(xiàn)的插件 在獲取intance()的時候會是空值
            posted @ 2012-04-30 20:34 ccsdu2009 閱讀(425) | 評論 (0)編輯 收藏
             
            #include <QThread>
            #include 
            <QMutex>
            #include 
            <QWaitCondition>
            #include 
            <QQueue>
            #include 
            <QVariant>
            #include 
            <iostream>

            const int DataSize = 100;
            const int BufferSize = 20;

            QQueue
            <QVariant> queue;
            QWaitCondition bufferIsNotFull;
            QWaitCondition bufferIsNotEmpty;
            QMutex mutex;
            QMutex printMutex;

            void print(int flag,int var)
            {
                printMutex.
            lock();
                
            if(flag == 0)
                    std::cout
            <<"set:"<<var<<std::endl;
                
            else
                    std::cout
            <<"get:"<<var<<std::endl;
                printMutex.unlock();
            }

            class Producer : public QThread
            {
            public:
                
            void run();
            };

            void Producer::run()
            {
                
            for(int i = 0; i < DataSize; ++i) 
                {
                    mutex.
            lock();
                    
            while(queue.size() == BufferSize)
                        bufferIsNotFull.wait(
            &mutex);
                    
            int var = std::rand()%10;
                    print(
            0,var);
                    queue.append(var);
                    bufferIsNotEmpty.wakeAll();
                    mutex.unlock();
                }
            }

            class Consumer : public QThread
            {
            public:
                
            void run();
            };

            void Consumer::run()
            {
                
            while(1)
                {
                    mutex.
            lock();
                    
            while(queue.isEmpty())
                        bufferIsNotEmpty.wait(
            &mutex);
                    
            int var = queue.dequeue().toInt();
                    print(
            1,var);
                    bufferIsNotFull.wakeAll();
                    mutex.unlock();
                }
            }
             
            int main()
            {
                Producer producer1;
                Consumer consumer1;
                Producer producer2;
                Consumer consumer2;
                producer1.start();
                consumer1.start();
                producer2.wait();
                consumer2.wait();
                system(
            "pause");
                
            return 0;
            }
            posted @ 2012-04-27 22:12 ccsdu2009 閱讀(4105) | 評論 (0)編輯 收藏
             
            QT中QSyntaxHighlighter主要和QTextEdit配合使用,高亮顯示關(guān)鍵字
            一個簡單的例子如下:
            #ifndef HIGHLIGHTER_H
            #define HIGHLIGHTER_H
            #include 
            <QSyntaxHighlighter>
            #include 
            <QTextCharFormat>

            QT_BEGIN_NAMESPACE
            class QTextDocument;
            QT_END_NAMESPACE

            class Highlighter : public QSyntaxHighlighter
            {
                Q_OBJECT
            public:
                Highlighter(QTextDocument 
            *parent = 0);
            public slots:
                
            void setTextQueue(const QStringList& textQueue);
            protected:
                
            void highlightBlock(const QString &text);
            private:
                
            struct HighlightingRule
                {
                    QRegExp pattern;
                    QTextCharFormat format;
                };
                QVector
            <HighlightingRule> highlightingRules;
                QTextCharFormat keywordFormat;
            };

            #endif
            .cpp
            #include <QtGui>
            #include 
            "highlighter.h"

            Highlighter::Highlighter(QTextDocument 
            *parent)
                : QSyntaxHighlighter(parent)
            {
                HighlightingRule rule;

                keywordFormat.setForeground(Qt::darkRed);
                keywordFormat.setFontWeight(QFont::Bold);
            }

            void Highlighter::highlightBlock(const QString &text)
            {
                
            foreach(const HighlightingRule &rule,highlightingRules) 
                {
                    QRegExp expression(rule.pattern);
                    
            int index = expression.indexIn(text);
                    
            while(index >= 0
                    {
                        
            int length = expression.matchedLength();
                        setFormat(index,length,rule.format);
                        index 
            = expression.indexIn(text, index + length);
                    }
                }
                setCurrentBlockState(
            0);
            }

            void Highlighter::setTextQueue(const QStringList& textQueue)
            {
                highlightingRules.clear();
                HighlightingRule rule;

                
            const QString tmp("\\b");
                
            foreach(const QString& str,textQueue)
                {   
                    QString pattern(tmp);
                    pattern 
            += str;
                    pattern 
            += tmp;
                    rule.pattern 
            = QRegExp(pattern);
                    rule.format 
            = keywordFormat;
                    highlightingRules.append(rule);
                }
            }
            在這里setTextQueue是傳入高亮顯示的文本列表
            posted @ 2012-04-21 22:59 ccsdu2009 閱讀(2943) | 評論 (0)編輯 收藏
             
            1.QString to const char*
                  QString string;
                  const char* str = string.toLatin1.data();
                  當(dāng)然也可以 const char* s = string.toStdString().c_str();
            2.QByteArray to char*     
                  QByteArray arrary;
                  char* ch = arrary.data();
            3.QString to QByteArray
                  QString str;
                  QByteArray array = str.toUtf8();
             
            posted @ 2012-04-07 22:26 ccsdu2009 閱讀(940) | 評論 (0)編輯 收藏
             
            出現(xiàn)這個錯誤的原因在于在次線程中執(zhí)行主線程對象的一些操作引起的
            可以這樣修改
            如果次線程需要更新主線程對象狀態(tài),需要發(fā)送消息,主線程對象接收后處理而不能在此線程中直接操作
            posted @ 2012-03-24 22:54 ccsdu2009 閱讀(8032) | 評論 (1)編輯 收藏
             
            默認(rèn)情況下QT是不支持中文的,一般在程序啟動的時候調(diào)用以下代碼,設(shè)置系統(tǒng)編碼方式即可
            1 QTextCodec*codec= QTextCodec::codecForName("System");
            2 QTextCodec::setCodecForLocale(codec);
            3 QTextCodec::setCodecForCStrings(codec);
            4 QTextCodec::setCodecForTr(codec);
            5 
            posted @ 2012-03-22 21:58 ccsdu2009 閱讀(515) | 評論 (1)編輯 收藏
             
            簡單的例子如下:
            #include <stdio.h>
            #include 
            <ao/ao.h>
            #include 
            <sndfile.h>
            #include 
            <math.h>

            int main(int argc, char **argv)
            {   
                SNDFILE
            *    infile = 0;
                SF_INFO        sfinfo;
                
            int            readcount;
                
                
            int rate = 44100;
                
            int channels = 2;
                
                
            if(!(infile = sf_open("rock.wav",SFM_READ,&sfinfo)))
                {   
                    
            return  1 ;
                };
                
                rate 
            = sfinfo.samplerate;
                printf(
            "rate %d\n",rate);
                channels 
            = sfinfo.channels;
                printf(
            "channels %d\n",channels);
                printf(
            "format %d\n",sfinfo.format);
             
                
            short data[4096];
                ao_device 
            *device;
                ao_sample_format format;
                
            int default_driver;
                
            int i;

                ao_initialize();

                default_driver 
            = ao_default_driver_id();
                memset(
            &format, 0sizeof(format));
                format.bits 
            = 16;
                format.channels 
            = channels;
                format.rate 
            = rate;
                format.byte_format 
            = AO_FMT_LITTLE;

                device 
            = ao_open_live(default_driver,&format, NULL);
                
            if(device == NULL) 
                {
                    fprintf(stderr,
            "error opening device.\n");
                    
            return 1;
                }
                 
                
            while((readcount = sf_read_short(infile,data,4096)))
                {   
                    ao_play(device,data,readcount
            *2);
                };

                sf_close (infile) ;
                ao_close(device);
                ao_shutdown();
                
            return (0);
            }
            posted @ 2012-03-20 22:38 ccsdu2009 閱讀(984) | 評論 (0)編輯 收藏
             
            輸出到控制臺
            #include <iostream>
            #include 
            <log4cplus/helpers/loglog.h>

            using namespace std;
            using namespace log4cplus::helpers;

            void print_message() 
            {
                cout 
            << "Entering print_message()" << endl;
                LogLog::getLogLog()
            ->debug(LOG4CPLUS_TEXT("This is a Debug statement"));
                LogLog::getLogLog()
            ->warn(LOG4CPLUS_TEXT("This is a Warning"));
                LogLog::getLogLog()
            ->error(LOG4CPLUS_TEXT("This is a Error"));
                cout 
            << "Exiting print_message()" << endl << endl;
            }

            int main() 
            {
                print_message();

                cout 
            << "Turning on debug" << endl;
                LogLog::getLogLog()
            ->setInternalDebugging(true);
                print_message();

                cout 
            << "Turning on quiet mode" << endl;
                LogLog::getLogLog()
            ->setQuietMode(true);
                print_message();
                system(
            "pause");
                
            return 0;
            }
            另外一個例子:
            #include "log4cplus/logger.h"
            #include 
            "log4cplus/consoleappender.h"
            #include 
            "log4cplus/loglevel.h"
            #include 
            <iomanip>

            using namespace std;
            using namespace log4cplus;

            int main()
            {
                SharedAppenderPtr append_1(
            new ConsoleAppender());
                append_1
            ->setName(LOG4CPLUS_TEXT("First"));
                Logger::getRoot().addAppender(append_1);

                Logger root 
            = Logger::getRoot();
                Logger test 
            = Logger::getInstance(LOG4CPLUS_TEXT("test"));

                LOG4CPLUS_DEBUG(root,
                                
            "This is"
                                
            << " a reall"
                                
            << "y long message." << endl
                                
            << "Just testing it out" << endl
                                
            << "What do you think?");
                test.setLogLevel(NOT_SET_LOG_LEVEL);
                LOG4CPLUS_DEBUG(test, 
            "This is a bool: " << true);
                LOG4CPLUS_INFO(test, 
            "This is a char: " << 'x');
                LOG4CPLUS_INFO(test, 
            "This is a short: " << (short)-100);
                LOG4CPLUS_INFO(test, 
            "This is a unsigned short: " << (unsigned short)100);
                LOG4CPLUS_INFO(test, 
            "This is a int: " << (int)1000);
                LOG4CPLUS_INFO(test, 
            "This is a unsigned int: " << (unsigned int)1000);
                LOG4CPLUS_INFO(test, 
            "This is a long(hex): " << hex << (long)100000000);
                LOG4CPLUS_INFO(test, 
            "This is a unsigned long: " << (unsigned long)100000000);
                LOG4CPLUS_WARN(test, 
            "This is a float: " << (float)1.2345);
                LOG4CPLUS_ERROR(test, 
                                
            "This is a double: " 
                                
            << setprecision(15
                                
            << (double)1.2345234234);
                LOG4CPLUS_FATAL(test, 
                                
            "This is a long double: " 
                                
            << setprecision(15
                                
            << (long double)123452342342.342);
                system(
            "pause");
                
            return 0;
            }
            再來看幾個輸出到日志的小例子:
            #include <log4cplus/logger.h>
            #include 
            <log4cplus/fileappender.h>
            #include 
            <log4cplus/layout.h>
            #include 
            <log4cplus/ndc.h>
            #include 
            <log4cplus/helpers/loglog.h>

            using namespace log4cplus;

            const int LOOP_COUNT = 20000;

            int main()
            {
                helpers::LogLog::getLogLog()
            ->setInternalDebugging(true);
                SharedAppenderPtr append_1(
            new RollingFileAppender(LOG4CPLUS_TEXT("Test.log"),5*1024,5));
                append_1
            ->setName(LOG4CPLUS_TEXT("LOG4PLUS"));
                append_1
            ->setLayout(std::auto_ptr<Layout>(new TTCCLayout()));
                Logger::getRoot().addAppender(append_1);

                Logger root 
            = Logger::getRoot();
                Logger test 
            = Logger::getInstance(LOG4CPLUS_TEXT("test"));
                Logger subTest 
            = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest"));

                
            for(int i=0; i<LOOP_COUNT; ++i) 
                {
                    NDCContextCreator _context(LOG4CPLUS_TEXT(
            "loop"));
                    LOG4CPLUS_DEBUG(subTest, 
            "Entering loop #" << i);
                }

                
            return 0
            }

            幾點(diǎn)說明:
            1.setInternalDebuging 是啟用內(nèi)部調(diào)試日志,不過具體作用不是很明確
            2.Appender是實(shí)現(xiàn)日志輸出的策略描述
            一般情況下,參考以上例子就足夠了
            posted @ 2012-03-15 22:22 ccsdu2009 閱讀(990) | 評論 (1)編輯 收藏
             
            #include <Qt/QFile.h>
            #include 
            <Qt/QDom.h>
            #include 
            <iostream>

            void showNodeInfo(const QDomNode& node)
            {
                std::cout
            <<"node name:"<<node.nodeName().toStdString()<<std::endl;
                QDomNode subnode 
            = node.firstChild();
                std::cout
            <<" node id:"<<subnode.nodeName().toStdString()<<std::endl;
                std::cout
            <<" node id value:"<<subnode.toElement().text().toStdString()<<std::endl;
                subnode 
            = subnode.nextSibling();
                std::cout
            <<" node name:"<<subnode.nodeName().toStdString()<<std::endl;
                std::cout
            <<" node name value:"<<subnode.toElement().text().toStdString()<<std::endl;
                subnode 
            = subnode.nextSibling();
                std::cout
            <<" node prefix:"<<subnode.nodeName().toStdString()<<std::endl;
                std::cout
            <<" node prefix value:"<<subnode.toElement().text().toStdString()<<std::endl;
            }

            int main(int argc, char *argv[])
            {
                QDomDocument doc;
                QFile xmlfile(
            "config.xml");
                
            if(!xmlfile.open(QIODevice::ReadOnly))return false;
                
            if(doc.setContent(&xmlfile))
                {
                    QDomElement root 
            = doc.documentElement();
                    QDomNode node 
            = root.firstChild();
                    
            for(;node.isNull()!=true;node=node.nextSibling())
                        showNodeInfo(node);
                }
                system(
            "pause");
                
            return 1;
            }

            基本步驟:
            1.使用QFile載入文件
            2.給QDomDocument設(shè)置文件內(nèi)容
            3.從QDomDocument獲取文檔根節(jié)點(diǎn)
            4.遍歷節(jié)點(diǎn)并作處理
            posted @ 2012-01-15 21:25 ccsdu2009 閱讀(1342) | 評論 (0)編輯 收藏
            僅列出標(biāo)題
            共38頁: First 13 14 15 16 17 18 19 20 21 Last 
             
            久久99精品久久久久久hb无码| 国产三级久久久精品麻豆三级| 国内精品伊人久久久久AV影院| 欧美性大战久久久久久| 国产成人香蕉久久久久| 99久久99久久| 亚洲国产精品久久久久久| 996久久国产精品线观看| 久久精品中文字幕无码绿巨人| 国产成人精品久久| 一本一本久久a久久综合精品蜜桃| 一本综合久久国产二区| 伊人久久一区二区三区无码| 久久国产成人午夜AV影院| 99久久精品免费看国产一区二区三区| 热99re久久国超精品首页| 久久久中文字幕| 久久久久国产亚洲AV麻豆| 久久无码AV中文出轨人妻| 午夜精品久久久久久影视777 | 久久精品综合网| 亚洲精品成人网久久久久久| 人妻无码αv中文字幕久久琪琪布 人妻无码精品久久亚瑟影视 | 精品久久久久久久| 精品久久久久久综合日本| 亚洲国产精品婷婷久久| 国产精品99久久久久久www| 久久久久亚洲AV无码专区网站| 亚洲精品无码久久久| 久久妇女高潮几次MBA| 日韩精品久久久久久免费| 久久精品国产精品国产精品污| 91久久精品无码一区二区毛片| 久久影院久久香蕉国产线看观看| 国内精品伊人久久久久妇| 亚洲综合伊人久久大杳蕉| 国产精品99久久久久久人| 国产成人综合久久精品尤物| 伊人久久五月天| 狠狠色噜噜狠狠狠狠狠色综合久久| 精品久久久久久国产免费了|