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

📄 canvas-chart-example.html

📁 QT 下载资料仅供参考
💻 HTML
📖 第 1 页 / 共 3 页
字号:
}void <a name="f559"></a>ChartForm::fileSaveAs(){    <a href="qstring.html">QString</a> filename = QFileDialog::<a href="qfiledialog.html#getSaveFileName">getSaveFileName</a>(                            QString::null, "Charts (*.cht)", this,                            "file save as", "Chart -- File Save As" );    if ( !filename.<a href="qstring.html#isEmpty">isEmpty</a>() ) {        int answer = 0;<a name="x2595"></a>        if ( QFile::<a href="qfile.html#exists">exists</a>( filename ) )<a name="x2606"></a>            answer = QMessageBox::<a href="qmessagebox.html#warning">warning</a>(                            this, "Chart -- Overwrite File",                            QString( "Overwrite\n\'%1\'?" ).                                arg( filename ),                            "&amp;Yes", "&amp;No", QString::null, 1, 1 );        if ( answer == 0 ) {            m_filename = filename;            updateRecentFiles( filename );            fileSave();            return;        }    }    <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Saving abandoned", 2000 );}void <a name="f560"></a>ChartForm::fileOpenRecent( int index ){    if ( !okToClear() )        return;    load( m_recentFiles[index] );}void <a name="f561"></a>ChartForm::updateRecentFiles( const <a href="qstring.html">QString</a>&amp; filename ){    if ( m_recentFiles.find( filename ) != m_recentFiles.end() )        return;    m_recentFiles.push_back( filename );    if ( m_recentFiles.count() &gt; MAX_RECENTFILES )        m_recentFiles.pop_front();    updateRecentFilesMenu();}void <a name="f562"></a>ChartForm::updateRecentFilesMenu(){    for ( int i = 0; i &lt; MAX_RECENTFILES; ++i ) {<a name="x2599"></a>        if ( fileMenu-&gt;<a href="qmenudata.html#findItem">findItem</a>( i ) )<a name="x2602"></a>            fileMenu-&gt;<a href="qmenudata.html#removeItem">removeItem</a>( i );        if ( i &lt; int(m_recentFiles.count()) )            fileMenu-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( QString( "&amp;%1 %2" ).                                    arg( i + 1 ).arg( m_recentFiles[i] ),                                  this, SLOT( fileOpenRecent(int) ),                                  0, i );    }}void <a name="f563"></a>ChartForm::fileQuit(){    if ( okToClear() ) {        saveOptions();<a name="x2592"></a>        qApp-&gt;<a href="qapplication.html#exit">exit</a>( 0 );    }}bool <a name="f564"></a>ChartForm::okToClear(){    if ( m_changed ) {        <a href="qstring.html">QString</a> msg;        if ( m_filename.isEmpty() )            msg = "Unnamed chart ";        else            msg = QString( "Chart '%1'\n" ).arg( m_filename );        msg += "has been changed.";<a name="x2605"></a>        switch( QMessageBox::<a href="qmessagebox.html#information">information</a>( this, "Chart -- Unsaved Changes",                                          msg, "&amp;Save", "Cancel", "&amp;Abandon",                                          0, 1 ) ) {            case 0:                fileSave();                break;            case 1:            default:                return false;                break;            case 2:                break;        }    }    return true;}void <a name="f565"></a>ChartForm::saveOptions(){    <a href="qsettings.html">QSettings</a> settings;    settings.<a href="qsettings.html#insertSearchPath">insertSearchPath</a>( QSettings::Windows, WINDOWS_REGISTRY );<a name="x2610"></a>    settings.<a href="qsettings.html#writeEntry">writeEntry</a>( APP_KEY + "WindowWidth", width() );    settings.<a href="qsettings.html#writeEntry">writeEntry</a>( APP_KEY + "WindowHeight", height() );    settings.<a href="qsettings.html#writeEntry">writeEntry</a>( APP_KEY + "WindowX", x() );    settings.<a href="qsettings.html#writeEntry">writeEntry</a>( APP_KEY + "WindowY", y() );    settings.<a href="qsettings.html#writeEntry">writeEntry</a>( APP_KEY + "ChartType", int(m_chartType) );    settings.<a href="qsettings.html#writeEntry">writeEntry</a>( APP_KEY + "AddValues", int(m_addValues) );    settings.<a href="qsettings.html#writeEntry">writeEntry</a>( APP_KEY + "Decimals", m_decimalPlaces );    settings.<a href="qsettings.html#writeEntry">writeEntry</a>( APP_KEY + "Font", m_font.toString() );    for ( int i = 0; i &lt; int(m_recentFiles.count()); ++i )        settings.<a href="qsettings.html#writeEntry">writeEntry</a>( APP_KEY + "File" + QString::number( i + 1 ),                             m_recentFiles[i] );}void <a name="f566"></a>ChartForm::optionsSetData(){    SetDataForm *setDataForm = new SetDataForm( &amp;m_elements, m_decimalPlaces, this );<a name="x2594"></a>    if ( setDataForm-&gt;<a href="qdialog.html#exec">exec</a>() ) {        m_changed = true;        drawElements();    }    delete setDataForm;}void <a name="f567"></a>ChartForm::setChartType( ChartType chartType ){    m_chartType = chartType;    switch ( m_chartType ) {        case PIE:<a name="x2588"></a>            optionsPieChartAction-&gt;<a href="qaction.html#setOn">setOn</a>( true );            break;        case VERTICAL_BAR:            optionsVerticalBarChartAction-&gt;<a href="qaction.html#setOn">setOn</a>( true );            break;        case HORIZONTAL_BAR:            optionsHorizontalBarChartAction-&gt;<a href="qaction.html#setOn">setOn</a>( true );            break;    }}void <a name="f568"></a>ChartForm::updateChartType( <a href="qaction.html">QAction</a> *action ){    if ( action == optionsPieChartAction ) {        m_chartType = PIE;    }    else if ( action == optionsHorizontalBarChartAction ) {        m_chartType = HORIZONTAL_BAR;    }    else if ( action == optionsVerticalBarChartAction ) {        m_chartType = VERTICAL_BAR;    }    drawElements();}void <a name="f569"></a>ChartForm::optionsSetFont(){    bool ok;<a name="x2598"></a>    <a href="qfont.html">QFont</a> font = QFontDialog::<a href="qfontdialog.html#getFont">getFont</a>( &amp;ok, m_font, this );    if ( ok ) {        m_font = font;        drawElements();    }}void <a name="f570"></a>ChartForm::optionsSetOptions(){    OptionsForm *optionsForm = new OptionsForm( this );    optionsForm-&gt;chartTypeComboBox-&gt;setCurrentItem( m_chartType );    optionsForm-&gt;<a href="qwidget.html#setFont">setFont</a>( m_font );    switch ( m_addValues ) {        case NO:            optionsForm-&gt;noRadioButton-&gt;setChecked( true );            break;        case YES:            optionsForm-&gt;yesRadioButton-&gt;setChecked( true );            break;        case AS_PERCENTAGE:            optionsForm-&gt;asPercentageRadioButton-&gt;setChecked( true );            break;    }    optionsForm-&gt;decimalPlacesSpinBox-&gt;setValue( m_decimalPlaces );    if ( optionsForm-&gt;<a href="qdialog.html#exec">exec</a>() ) {        setChartType( ChartType(                optionsForm-&gt;chartTypeComboBox-&gt;currentItem()) );<a name="x2615"></a>        m_font = optionsForm-&gt;<a href="qwidget.html#font">font</a>();        if ( optionsForm-&gt;noRadioButton-&gt;isChecked() )            m_addValues = NO;        else if ( optionsForm-&gt;yesRadioButton-&gt;isChecked() )            m_addValues = YES;        else if ( optionsForm-&gt;asPercentageRadioButton-&gt;isChecked() )            m_addValues = AS_PERCENTAGE;        m_decimalPlaces = optionsForm-&gt;decimalPlacesSpinBox-&gt;value();        drawElements();    }    delete optionsForm;}void <a name="f571"></a>ChartForm::helpHelp(){    <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Help is not implemented yet", 2000 );}void <a name="f572"></a>ChartForm::helpAbout(){<a name="x2603"></a>    QMessageBox::<a href="qmessagebox.html#about">about</a>( this, "Chart -- About",                        "&lt;center&gt;&lt;h1&gt;&lt;font color=blue&gt;Chart&lt;font&gt;&lt;/h1&gt;&lt;/center&gt;"                        "&lt;p&gt;Chart your data with &lt;i&gt;chart&lt;/i&gt;.&lt;/p&gt;"                        );}void <a name="f573"></a>ChartForm::helpAboutQt(){<a name="x2604"></a>    QMessageBox::<a href="qmessagebox.html#aboutQt">aboutQt</a>( this, "Chart -- About Qt" );}</pre><p> <hr><p> Main:<p> <pre>#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;#include "chartform.h"int main( int argc, char *argv[] ){    <a href="qapplication.html">QApplication</a> app( argc, argv );    <a href="qstring.html">QString</a> filename;<a name="x2618"></a>    if ( app.<a href="qapplication.html#argc">argc</a>() &gt; 1 ) {<a name="x2619"></a>        filename = app.<a href="qapplication.html#argv">argv</a>()[1];<a name="x2624"></a>        if ( !filename.<a href="qstring.html#endsWith">endsWith</a>( ".cht" ) )            filename = QString::null;    }    ChartForm *cf = new ChartForm( filename );    app.<a href="qapplication.html#setMainWidget">setMainWidget</a>( cf );    cf-&gt;<a href="qwidget.html#show">show</a>();<a name="x2621"></a>    app.<a href="qobject.html#connect">connect</a>( &amp;app, SIGNAL(<a href="qapplication.html#lastWindowClosed">lastWindowClosed</a>()), cf, SLOT(fileQuit()) );    return app.<a href="qapplication.html#exec">exec</a>();}</pre><p> <p>See also <a href="step-by-step-examples.html">Step-by-step Examples</a>.<!-- eof --><p><address><hr><div align=center><table width=100% cellspacing=0 border=0><tr><td>Copyright &copy; 2002 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a><td align=right><div align=right>Qt version 3.0.5</div></table></div></address></body></html>

⌨️ 快捷键说明

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