⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 progress-progress-cpp.html

📁 qtopiaphone英文帮助,用于初学者和开发人员,初学者可以用来学习,开发人员可以用来资料查询.
💻 HTML
📖 第 1 页 / 共 2 页
字号:
        file-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "Quit", qApp,  SLOT(quit()) );        options = new <a href="qpopupmenu.html">QPopupMenu</a>();        CHECK_PTR( options );        menubar-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "&amp;Options", options );        td_id = options-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "Timer driven", this, SLOT(timerDriven()) );        ld_id = options-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "Loop driven", this, SLOT(loopDriven()) );        options-&gt;<a href="qmenudata.html#e34b79">insertSeparator</a>();        dl_id = options-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "Default label", this, SLOT(defaultLabel()) );        cl_id = options-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "Custom label", this, SLOT(customLabel()) );        options-&gt;<a href="qmenudata.html#e34b79">insertSeparator</a>();        md_id = options-&gt;<a href="qmenudata.html#deddb9">insertItem</a>( "No minimum duration", this, SLOT(toggleMinimumDuration()) );        options-&gt;<a name="setCheckable"></a><a href="qpopupmenu.html#672d77">setCheckable</a>( TRUE );        loopDriven();        defaultLabel();        setFixedSize( 400, 300 );        setBackgroundColor( black );    }public slots:    void doMenuItem(int id)    {        if (id &gt;= first_draw_item &amp;&amp; id &lt;= last_draw_item)            draw(drawItemRects(id));    }    void stopDrawing() { got_stop = TRUE; }    void timerDriven()    {        timer_driven = TRUE;        options-&gt;<a name="setItemChecked"></a><a href="qmenudata.html#319c05">setItemChecked</a>( td_id, TRUE );        options-&gt;<a href="qmenudata.html#319c05">setItemChecked</a>( ld_id, FALSE );    }    void loopDriven()    {        timer_driven = FALSE;        options-&gt;<a href="qmenudata.html#319c05">setItemChecked</a>( ld_id, TRUE );        options-&gt;<a href="qmenudata.html#319c05">setItemChecked</a>( td_id, FALSE );    }    void defaultLabel()    {        default_label = TRUE;        options-&gt;<a href="qmenudata.html#319c05">setItemChecked</a>( dl_id, TRUE );        options-&gt;<a href="qmenudata.html#319c05">setItemChecked</a>( cl_id, FALSE );    }    void customLabel()    {        default_label = FALSE;        options-&gt;<a href="qmenudata.html#319c05">setItemChecked</a>( dl_id, FALSE );        options-&gt;<a href="qmenudata.html#319c05">setItemChecked</a>( cl_id, TRUE );    }    void toggleMinimumDuration()    {        options-&gt;<a href="qmenudata.html#319c05">setItemChecked</a>( md_id,            !options-&gt;<a name="isItemChecked"></a><a href="qmenudata.html#def7a0">isItemChecked</a>( md_id ) );    }private:    void timerEvent( <a href="qtimerevent.html">QTimerEvent</a>* )    {        pb-&gt;<a name="setProgress"></a><a href="qprogressdialog.html#037f30">setProgress</a>( pb-&gt;<a name="totalSteps"></a><a href="qprogressdialog.html#25744a">totalSteps</a>() - rects );        rects--;        {            <a href="qpainter.html">QPainter</a> p(this);            int ww = width();            int wh = height();            if ( ww &gt; 8 &amp;&amp; wh &gt; 8 ) {                <a href="qcolor.html">QColor</a> c(rand()%255, rand()%255, rand()%255);                int x = rand() % (ww-8);                int y = rand() % (wh-8);                int w = rand() % (ww-x);                int h = rand() % (wh-y);                p.<a name="fillRect"></a><a href="qpainter.html#5308a7">fillRect</a>( x, y, w, h, c );            }        }        if (!rects || got_stop) {            pb-&gt;<a href="qprogressdialog.html#037f30">setProgress</a>( pb-&gt;<a href="qprogressdialog.html#25744a">totalSteps</a>() );            <a href="qpainter.html">QPainter</a> p(this);            p.<a href="qpainter.html#5308a7">fillRect</a>(0, 0, width(), height(), backgroundColor());            enableDrawingItems(TRUE);            killTimers();            delete pb;            pb = 0;        }    }    <a name="QProgressDialog"></a><a href="qprogressdialog.html">QProgressDialog</a>* newProgressDialog( const char* label, int steps, bool modal )    {        <a href="qprogressdialog.html">QProgressDialog</a> *d = new <a href="qprogressdialog.html">QProgressDialog</a>(label, "Cancel", steps, this,                                                 "progress", modal);        if ( options-&gt;<a href="qmenudata.html#def7a0">isItemChecked</a>( md_id ) )            d-&gt;<a name="setMinimumDuration"></a><a href="qprogressdialog.html#6c1a6c">setMinimumDuration</a>(0);        if ( !default_label )            d-&gt;<a name="setLabel"></a><a href="qprogressdialog.html#077342">setLabel</a>( new AnimatedThingy(d,label) );        return d;    }    void enableDrawingItems(bool yes)    {        for (int i=first_draw_item; i&lt;=last_draw_item; i++) {            menubar-&gt;<a name="setItemEnabled"></a><a href="qmenudata.html#c9a23c">setItemEnabled</a>(i, yes);        }    }    void draw(int n)    {        if ( timer_driven ) {            if ( pb ) {                <a name="qWarning"></a><a href="qapplication.html#290ef4">qWarning</a>("This cannot happen!");                return;            }            rects = n;            pb = newProgressDialog("Drawing rectangles.\n"                                   "Using timer event.", n, FALSE);            pb-&gt;<a name="setCaption"></a><a href="qwidget.html#d6a291">setCaption</a>("Please Wait");            connect(pb, SIGNAL(cancelled()), this, SLOT(stopDrawing()));            enableDrawingItems(FALSE);            startTimer(0);            got_stop = FALSE;        } else {            <a href="qprogressdialog.html">QProgressDialog</a>* lpb = newProgressDialog(                        "Drawing rectangles.\nUsing loop.", n, TRUE);            lpb-&gt;<a href="qwidget.html#d6a291">setCaption</a>("Please Wait");            <a href="qpainter.html">QPainter</a> p(this);            for (int i=0; i&lt;n; i++) {                lpb-&gt;<a href="qprogressdialog.html#037f30">setProgress</a>(i);                if ( lpb-&gt;<a name="wasCancelled"></a><a href="qprogressdialog.html#9818b6">wasCancelled</a>() )                    break;                <a href="qcolor.html">QColor</a> c(rand()%255, rand()%255, rand()%255);                int x = rand()%(width()-8);                int y = rand()%(height()-8);                int w = rand()%(width()-x);                int h = rand()%(height()-y);                p.<a href="qpainter.html#5308a7">fillRect</a>(x,y,w,h,c);            }            p.<a href="qpainter.html#5308a7">fillRect</a>(0, 0, width(), height(), backgroundColor());            delete lpb;        }    }    <a href="qmenubar.html">QMenuBar</a>* menubar;    <a href="qprogressdialog.html">QProgressDialog</a>* pb;    <a href="qpopupmenu.html">QPopupMenu</a>* options;    int td_id, ld_id;    int dl_id, cl_id;    int md_id;    int rects;    bool timer_driven;    bool default_label;    bool got_stop;};int main( int argc, char **argv ){    <a name="QApplication"></a><a href="qapplication.html">QApplication</a> a( argc, argv );    int wincount = argc &gt; 1 ? atoi(argv[1]) : 1;    for ( int i=0; i&lt;wincount; i++ ) {        CPUWaster* cpuw = new CPUWaster;        if ( i == 0 ) a.<a name="setMainWidget"></a><a href="qapplication.html#7ad759">setMainWidget</a>(cpuw);        cpuw-&gt;<a href="qwidget.html#d6a291">setCaption</a>("Qt Example - Progress");        cpuw-&gt;<a href="qwidget.html#200ee5">show</a>();    }    return a.<a name="exec"></a><a href="qapplication.html#84c7bf">exec</a>();}#include "progress.moc"</pre><p><address><hr><div align="center"><table width="100%" cellspacing="0" border="0"><tr><td>Copyright 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -