• <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é)點文本
                TidyBuffer buf;
                tidyBufInit(
            &buf);
                tidyNodeGetText(doc,body,
            &buf);
                printf(
            "text:%s",buf.bp);
                tidyBufFree(
            &buf);
            posted @ 2012-05-05 16:43 ccsdu2009 閱讀(472) | 評論 (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 閱讀(430) | 評論 (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 閱讀(4108) | 評論 (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 閱讀(2954) | 評論 (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 閱讀(951) | 評論 (0)編輯 收藏
             
            出現(xiàn)這個錯誤的原因在于在次線程中執(zhí)行主線程對象的一些操作引起的
            可以這樣修改
            如果次線程需要更新主線程對象狀態(tài),需要發(fā)送消息,主線程對象接收后處理而不能在此線程中直接操作
            posted @ 2012-03-24 22:54 ccsdu2009 閱讀(8046) | 評論 (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 閱讀(520) | 評論 (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 閱讀(993) | 評論 (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
            }

            幾點說明:
            1.setInternalDebuging 是啟用內(nèi)部調(diào)試日志,不過具體作用不是很明確
            2.Appender是實現(xiàn)日志輸出的策略描述
            一般情況下,參考以上例子就足夠了
            posted @ 2012-03-15 22:22 ccsdu2009 閱讀(996) | 評論 (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é)點
            4.遍歷節(jié)點并作處理
            posted @ 2012-01-15 21:25 ccsdu2009 閱讀(1343) | 評論 (0)編輯 收藏
            僅列出標(biāo)題
            共38頁: First 13 14 15 16 17 18 19 20 21 Last 
             
            久久久久国产| 国产精品久久久久天天影视| 久久国产高清一区二区三区| 国产精品久久久天天影视香蕉| 国产精品gz久久久| 狠狠色丁香久久婷婷综合_中| 亚洲伊人久久成综合人影院| 精品综合久久久久久97| 91亚洲国产成人久久精品| 中文字幕无码av激情不卡久久| 久久精品国产亚洲精品2020| 精品久久人人做人人爽综合| 久久夜色精品国产噜噜麻豆 | 狠狠色丁香婷婷久久综合| 久久人人爽爽爽人久久久| 少妇熟女久久综合网色欲| 国产精品无码久久久久久| 国产美女亚洲精品久久久综合| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 国产L精品国产亚洲区久久| 亚洲精品乱码久久久久久蜜桃不卡| 久久777国产线看观看精品| 久久天天躁狠狠躁夜夜avapp| 91麻精品国产91久久久久| 99久久这里只有精品| 久久精品国产AV一区二区三区 | 久久精品国产亚洲av麻豆图片| 2021国产成人精品久久| 国产精品久久久久影院嫩草 | 国产午夜精品久久久久九九电影| 久久人人爽人人爽人人AV| 婷婷国产天堂久久综合五月| 久久精品国产欧美日韩| 久久国产美女免费观看精品 | 国产成人AV综合久久| 国产2021久久精品| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区| 伊人久久大香线蕉亚洲五月天| 亚洲国产成人久久综合野外| 久久综合久久性久99毛片| 久久人人爽人人爽人人片AV高清 |