• <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>

            天下

            記錄修行的印記

            qt對(duì)話框+線程小試

            //thread.h
            #pragma once
            #define QT3_SUPPORT
            #include 
            <iostream>
            #include 
            <cstdio>
            #include 
            <unistd.h>
            #include 
            <Qt/qapplication.h>
            #include 
            <Qt/qpushbutton.h>
            #include 
            <qmessagebox.h> 
            #include 
            <Qt/qdialog.h>
            #include 
            <Qt/qthread.h>
            #include 
            <QString>


            template
            <typename T>
            class Thread : public QThread
            {
            public:
                Thread();
                
            ~Thread();
                
            void run();
                
            void setTObj(T* pobj);
            public:
                
            int flag;
                unsigned 
            int pos;
                T
            * pTObj;
            };


            template
            <typename T>
            Thread
            <T>::Thread()
            {
                flag 
            = 1;
                pos 
            =0;
            }

            template
            <typename T>
            Thread
            <T>::~Thread()
            {

            }

            template
            <typename T>
            void Thread<T>::run()
            {
                
            //QMessageBox::information( NULL, "Application name","Started.\n");
                QString strText;
                
            while(flag)
                {
                    strText.sprintf(
            "flag:%d",pos);
                    pTObj
            ->setWindowTitle(strText);
                    pos
            ++;
                    QThread::msleep(
            500);
                }
            }

            template
            <typename T>
            void Thread<T>::setTObj(T* pobj)
            {
                pTObj 
            = pobj;
            }

            //ProcessDialog.h
            #pragma once
            #define QT3_SUPPORT

            #include 
            <iostream>
            #include 
            <cstdio>
            #include 
            <unistd.h>
            #include 
            <Qt/qapplication.h>
            #include 
            <Qt/qpushbutton.h>
            #include 
            <qmessagebox.h> 
            #include 
            <Qt/qdialog.h>
            #include 
            <Qt/qthread.h>
            #include 
            <QString>
            #include 
            "Thread.h"

            class ProcessDialog :public QDialog 
            {
                Q_OBJECT
            public:
                ProcessDialog(QWidget
            * parent=0)
                    :btnStop(
            "Stop",this)
                    ,btnWork(
            "Work",this)
                {
                    btnStop.setGeometry( 
            62407530 );
                    btnWork.setGeometry( 
            162,1407530 );

                    threadA.setTObj(
            this);

                    connect(
            &btnWork,SIGNAL( clicked()),this,SLOT(start()) );
                    connect(
            &btnStop,SIGNAL( clicked()),this,SLOT(stop()) );
                }

            public:
                QPushButton btnStop;
                QPushButton btnWork;
                
            private slots:
                    
            void start()
                    {
                        btnWork.setText(
            "Working");
                        threadA.start();
                        threadA.flag 
            = 1;
                    }
                    
            void stop()
                    {
                        btnWork.setText(
            "Work");
                        threadA.flag 
            = 0;
                        
            //threadA.pos  = 0;
                    }

            private:
                Thread
            <ProcessDialog> threadA;    
            };


            //main.cpp
            #define QT3_SUPPORT
            #include 
            <iostream>
            #include 
            <cstdio>
            #include 
            <unistd.h>
            #include 
            <Qt/qapplication.h>
            #include 
            <Qt/qpushbutton.h>
            #include 
            <qmessagebox.h> 
            #include 
            <Qt/qdialog.h>
            #include 
            <Qt/qthread.h>
            #include 
            <QString>
            #include 
            "Thread.h"
            #include 
            "ProcessDialog.h"

            int main( int argc, char **argv )
            {
                QApplication app( argc, argv );
                ProcessDialog dlg;
                app.setMainWidget( 
            &dlg );
                dlg.resize(
            640,480);
                dlg.setModal(
            true);
                dlg.exec();
                
            return app.exec();
            }

            posted on 2011-09-22 10:24 天下 閱讀(1101) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Linux編程QT

            <2015年12月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評(píng)論

            久久午夜无码鲁丝片秋霞| 久久亚洲国产中v天仙www| 亚洲欧美日韩精品久久亚洲区 | 久久精品国产乱子伦| 亚洲成色WWW久久网站| 久久美女人爽女人爽| 日韩十八禁一区二区久久| 99久久这里只精品国产免费| 久久精品中文无码资源站| 国产亚洲精久久久久久无码AV| 久久人人爽人人爽人人片AV东京热 | 欧美国产成人久久精品| 天堂久久天堂AV色综合| 99久久精品这里只有精品| 久久精品国产2020| A级毛片无码久久精品免费| 久久国产欧美日韩精品免费| 青青草国产精品久久久久| 亚洲AV无码久久| 无码乱码观看精品久久| 99久久免费国产精品热| 久久婷婷色综合一区二区| 精品国产热久久久福利| 国产精品久久久久影视不卡| 波多野结衣AV无码久久一区| 日本精品久久久久影院日本| 精品久久久久久中文字幕| 亚洲精品乱码久久久久久久久久久久 | 亚洲精品国产自在久久| 麻豆精品久久精品色综合| 欧美噜噜久久久XXX| 无码精品久久久久久人妻中字 | 久久久久亚洲AV无码麻豆| 2020久久精品亚洲热综合一本| 久久久青草青青国产亚洲免观| 精品久久久久久中文字幕| 久久久久免费看成人影片| 久久偷看各类wc女厕嘘嘘| 久久66热人妻偷产精品9| 精品国产乱码久久久久久郑州公司| 国产成人精品综合久久久久|