• <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對話框+線程小試

            //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 天下 閱讀(1108) 評論(0)  編輯 收藏 引用 所屬分類: Linux編程 、QT

            <2015年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            導航

            統計

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評論

            美女写真久久影院| 一97日本道伊人久久综合影院| 性欧美大战久久久久久久久| 无遮挡粉嫩小泬久久久久久久 | 久久精品国产亚洲av麻豆小说| 狠狠色丁香婷婷久久综合不卡| 久久99国产亚洲高清观看首页| 久久精品中文字幕第23页| 香蕉久久夜色精品升级完成| 久久久久一级精品亚洲国产成人综合AV区| 日本久久中文字幕| 国产成人精品久久二区二区| 亚洲色大成网站WWW久久九九| 久久亚洲精品国产精品婷婷| 久久精品一区二区三区中文字幕| 久久中文字幕人妻丝袜| 国产精品99久久久精品无码| 久久精品国产欧美日韩99热| 亚洲&#228;v永久无码精品天堂久久| 久久亚洲精品成人AV| 99精品国产综合久久久久五月天 | 无码人妻精品一区二区三区久久| 久久AAAA片一区二区| 2020最新久久久视精品爱| 热re99久久精品国产99热| 一本大道久久东京热无码AV| 亚洲午夜久久久久久久久久| 一级做a爰片久久毛片人呢| 国产精品视频久久久| 欧美伊人久久大香线蕉综合| 亚洲日本va中文字幕久久| 精品久久人人妻人人做精品| 久久天天躁狠狠躁夜夜不卡| 999久久久免费精品国产| 国产福利电影一区二区三区久久老子无码午夜伦不 | 日本人妻丰满熟妇久久久久久| 国产激情久久久久久熟女老人| 久久午夜无码鲁丝片| 国产亚洲精品久久久久秋霞| 日本精品久久久中文字幕| 久久久婷婷五月亚洲97号色 |