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

📄 fileiconview-main-cpp.html

📁 qtopiaphone英文帮助,用于初学者和开发人员,初学者可以用来学习,开发人员可以用来资料查询.
💻 HTML
📖 第 1 页 / 共 4 页
字号:
    for ( ; item; item = (QtFileIconViewItem*)item-&gt;<a href="qiconviewitem.html#005b99">nextItem</a>() )        item-&gt;viewModeChanged( vm );    <a href="qiconview.html#9fb7be">arrangeItemsInGrid</a>();}</pre>  <hr>  Header file of the mainwindow: <pre>/****************************************************************************** &#36;Id&#58; qt/examples/fileiconview/mainwindow.h   2.3.8   edited 2004-05-12 $**** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.**** This file is part of an example program for Qt.  This example** program may be used, distributed and modified without limitation.*******************************************************************************/#ifndef MAINWIN_H#define MAINWIN_H#include &lt;<a href="qmainwindow-h.html">qmainwindow.h</a>&gt;class QtFileIconView;class DirectoryView;class QProgressBar;class QLabel;class QComboBox;class QToolButton;class FileMainWindow : public QMainWindow{    Q_OBJECTpublic:    FileMainWindow();    QtFileIconView *fileView() { return fileview; }    DirectoryView *dirList() { return dirlist; }    void show();protected:    void setup();    void setPathCombo();    QtFileIconView *fileview;    DirectoryView *dirlist;    <a href="qprogressbar.html">QProgressBar</a> *progress;    <a href="qlabel.html">QLabel</a> *label;    <a href="qcombobox.html">QComboBox</a> *pathCombo;    <a href="qtoolbutton.html">QToolButton</a> *upButton, *mkdirButton;protected slots:    void directoryChanged( const QString &amp; );    void slotStartReadDir( int dirs );    void slotReadNextDir();    void slotReadDirDone();    void cdUp();    void newFolder();    void changePath( const QString &amp;path );    void enableUp();    void disableUp();    void enableMkdir();    void disableMkdir();};#endif</pre>  <hr>  Implementation of the mainwindow: <pre>/****************************************************************************** &#36;Id&#58; qt/examples/fileiconview/mainwindow.cpp   2.3.8   edited 2004-05-12 $**** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.**** This file is part of an example program for Qt.  This example** program may be used, distributed and modified without limitation.*******************************************************************************/#include "mainwindow.h"#include "qfileiconview.h"#include "../dirview/dirview.h"#include &lt;<a href="qsplitter-h.html">qsplitter.h</a>&gt;#include &lt;<a href="qprogressbar-h.html">qprogressbar.h</a>&gt;#include &lt;<a href="qlabel-h.html">qlabel.h</a>&gt;#include &lt;<a href="qstatusbar-h.html">qstatusbar.h</a>&gt;#include &lt;<a href="qtoolbar-h.html">qtoolbar.h</a>&gt;#include &lt;<a href="qcombobox-h.html">qcombobox.h</a>&gt;#include &lt;<a href="qpixmap-h.html">qpixmap.h</a>&gt;#include &lt;<a href="qtoolbutton-h.html">qtoolbutton.h</a>&gt;#include &lt;<a href="qdir-h.html">qdir.h</a>&gt;#include &lt;<a href="qfileinfo-h.html">qfileinfo.h</a>&gt;static const char* cdtoparent_xpm[]={    "15 13 3 1",    ". c None",    "* c #000000",    "a c #ffff99",    "..*****........",    ".*aaaaa*.......",    "***************",    "*aaaaaaaaaaaaa*",    "*aaaa*aaaaaaaa*",    "*aaa***aaaaaaa*",    "*aa*****aaaaaa*",    "*aaaa*aaaaaaaa*",    "*aaaa*aaaaaaaa*",    "*aaaa******aaa*",    "*aaaaaaaaaaaaa*",    "*aaaaaaaaaaaaa*",    "***************"};static const char* newfolder_xpm[] = {    "15 14 4 1",    "   c None",    ".  c #000000",    "+  c #FFFF00",    "@  c #FFFFFF",    "          .    ",    "               ",    "          .    ",    "       .     . ",    "  ....  . . .  ",    " .+@+@.  . .   ",    "..........  . .",    ".@+@+@+@+@..   ",    ".+@+@+@+@+. .  ",    ".@+@+@+@+@.  . ",    ".+@+@+@+@+.    ",    ".@+@+@+@+@.    ",    ".+@+@+@+@+.    ",    "...........    "};FileMainWindow::FileMainWindow()    : <a href="qmainwindow.html">QMainWindow</a>(){    <a href=#207>setup</a>();}void <a name="206"></a>FileMainWindow::show(){    <a href="qmainwindow.html#eb53e3">QMainWindow::show</a>();}void <a name="207"></a>FileMainWindow::setup(){    <a href="qsplitter.html">QSplitter</a> *splitter = new <a href="qsplitter.html">QSplitter</a>( this );    dirlist = new DirectoryView( splitter, "dirlist", TRUE );    dirlist-&gt;addColumn( "Name" );    dirlist-&gt;addColumn( "Type" );    Directory *root = new Directory( dirlist, "/" );    root-&gt;<a href="qlistviewitem.html#1c5a28">setOpen</a>( TRUE );    splitter-&gt;<a href="qsplitter.html#33bf83">setResizeMode</a>( dirlist, QSplitter::KeepSize );    fileview = new QtFileIconView( "/", splitter );    fileview-&gt;setSelectionMode( QIconView::Extended );    <a href="qmainwindow.html#fce9ba">setCentralWidget</a>( splitter );    <a href="qtoolbar.html">QToolBar</a> *toolbar = new <a href="qtoolbar.html">QToolBar</a>( this, "toolbar" );    <a href="qmainwindow.html#edcb2d">setRightJustification</a>( TRUE );    (void)new <a href="qlabel.html">QLabel</a>( <a href="qobject.html#2418a9">tr</a>( " Path: " ), toolbar );    pathCombo = new <a href="qcombobox.html">QComboBox</a>( TRUE, toolbar );    pathCombo-&gt;setAutoCompletion( TRUE );    toolbar-&gt;<a href="qtoolbar.html#7b948e">setStretchableWidget</a>( pathCombo );    <a href="qobject.html#fbde73">connect</a>( pathCombo, SIGNAL( activated( const QString &amp; ) ),             this, SLOT ( <a href=#215>changePath</a>( const QString &amp; ) ) );    toolbar-&gt;<a href="qtoolbar.html#af219d">addSeparator</a>();    <a href="qpixmap.html">QPixmap</a> pix;    pix = QPixmap( cdtoparent_xpm );    upButton = new <a href="qtoolbutton.html">QToolButton</a>( pix, "One directory up", QString::null,                                this, SLOT( <a href=#213>cdUp</a>() ), toolbar, "cd up" );    pix = QPixmap( newfolder_xpm );    mkdirButton = new <a href="qtoolbutton.html">QToolButton</a>( pix, "New Folder", QString::null,                                   this, SLOT( <a href=#214>newFolder</a>() ), toolbar, "new folder" );    <a href="qobject.html#fbde73">connect</a>( dirlist, SIGNAL( folderSelected( const QString &amp; ) ),             fileview, SLOT ( setDirectory( const QString &amp; ) ) );    <a href="qobject.html#fbde73">connect</a>( fileview, SIGNAL( <a href=#209>directoryChanged</a>( const QString &amp; ) ),             this, SLOT( <a href=#209>directoryChanged</a>( const QString &amp; ) ) );    <a href="qobject.html#fbde73">connect</a>( fileview, SIGNAL( startReadDir( int ) ),             this, SLOT( <a href=#210>slotStartReadDir</a>( int ) ) );    <a href="qobject.html#fbde73">connect</a>( fileview, SIGNAL( readNextDir() ),             this, SLOT( <a href=#211>slotReadNextDir</a>() ) );    <a href="qobject.html#fbde73">connect</a>( fileview, SIGNAL( readDirDone() ),             this, SLOT( <a href=#212>slotReadDirDone</a>() ) );    <a href="qmainwindow.html#712cb8">setDockEnabled</a>( Left, FALSE );    <a href="qmainwindow.html#712cb8">setDockEnabled</a>( Right, FALSE );    label = new <a href="qlabel.html">QLabel</a>( <a href="qmainwindow.html#530937">statusBar</a>() );    <a href="qmainwindow.html#530937">statusBar</a>()-&gt;addWidget( label, 2, TRUE );    progress = new <a href="qprogressbar.html">QProgressBar</a>( <a href="qmainwindow.html#530937">statusBar</a>() );    <a href="qmainwindow.html#530937">statusBar</a>()-&gt;addWidget( progress, 1, TRUE );    <a href="qobject.html#fbde73">connect</a>( fileview, SIGNAL( <a href=#216>enableUp</a>() ),             this, SLOT( <a href=#216>enableUp</a>() ) );    <a href="qobject.html#fbde73">connect</a>( fileview, SIGNAL( <a href=#217>disableUp</a>() ),             this, SLOT( <a href=#217>disableUp</a>() ) );    <a href="qobject.html#fbde73">connect</a>( fileview, SIGNAL( <a href=#218>enableMkdir</a>() ),             this, SLOT( <a href=#218>enableMkdir</a>() ) );    <a href="qobject.html#fbde73">connect</a>( fileview, SIGNAL( <a href=#219>disableMkdir</a>() ),             this, SLOT( <a href=#219>disableMkdir</a>() ) );}void <a name="208"></a>FileMainWindow::setPathCombo(){    <a href="qstring.html">QString</a> dir = caption();    int i = 0;    bool found = FALSE;    for ( i = 0; i &lt; pathCombo-&gt;count(); ++i ) {        if ( pathCombo-&gt;text( i ) == dir) {            found = TRUE;            break;        }    }    if ( found )        pathCombo-&gt;setCurrentItem( i );    else {        pathCombo-&gt;insertItem( dir );        pathCombo-&gt;setCurrentItem( pathCombo-&gt;count() - 1 );    }}void <a name="209"></a>FileMainWindow::directoryChanged( const QString &amp;dir ){    <a href="qwidget.html#d6a291">setCaption</a>( dir );    <a href=#208>setPathCombo</a>();}void <a name="210"></a>FileMainWindow::slotStartReadDir( int dirs ){    label-&gt;setText( <a href="qobject.html#2418a9">tr</a>( " Reading Directory..." ) );    progress-&gt;reset();    progress-&gt;setTotalSteps( dirs );}void <a name="211"></a>FileMainWindow::slotReadNextDir(){    int p = progress-&gt;progress();    progress-&gt;setProgress( ++p );}void <a name="212"></a>FileMainWindow::slotReadDirDone(){    label-&gt;setText( <a href="qobject.html#2418a9">tr</a>( " Reading Directory Done." ) );    progress-&gt;setProgress( progress-&gt;totalSteps() );}void <a name="213"></a>FileMainWindow::cdUp(){    <a href="qdir.html">QDir</a> dir = fileview-&gt;currentDir();    dir.<a href="qdir.html#f0fc10">cd</a>( ".." );    fileview-&gt;setDirectory( dir );}void <a name="214"></a>FileMainWindow::newFolder(){    fileview-&gt;newDirectory();}void <a name="215"></a>FileMainWindow::changePath( const QString &amp;path ){    if ( <a href="qfileinfo.html">QFileInfo</a>( path ).exists() )        fileview-&gt;setDirectory( path );    else        <a href=#208>setPathCombo</a>();}void <a name="216"></a>FileMainWindow::enableUp(){    upButton-&gt;setEnabled( TRUE );}void <a name="217"></a>FileMainWindow::disableUp(){    upButton-&gt;setEnabled( FALSE );}void <a name="218"></a>FileMainWindow::enableMkdir(){    mkdirButton-&gt;setEnabled( TRUE );}void <a name="219"></a>FileMainWindow::disableMkdir(){    mkdirButton-&gt;setEnabled( FALSE );}</pre>  <hr>  Main:<pre>/****************************************************************************** &#36;Id&#58; qt/examples/fileiconview/main.cpp   2.3.8   edited 2004-05-12 $**** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.**** This file is part of an example program for Qt.  This example** program may be used, distributed and modified without limitation.*******************************************************************************/#include "mainwindow.h"#include "qfileiconview.h"#include &lt;<a name="qapplication.h"></a><a href="qapplication-h.html">qapplication.h</a>&gt;int main( int argc, char **argv ){    <a name="QApplication"></a><a href="qapplication.html">QApplication</a> a( argc, argv );    FileMainWindow mw;    mw.<a name="resize"></a><a href="qwidget.html#ff9d07">resize</a>( 680, 480 );    a.<a name="setMainWidget"></a><a href="qapplication.html#7ad759">setMainWidget</a>( &amp;mw );    mw.fileView()-&gt;setDirectory( "/" );    mw.<a name="show"></a><a href="qmainwindow.html#eb53e3">show</a>();    return a.<a name="exec"></a><a href="qapplication.html#84c7bf">exec</a>();}</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 + -