#include <QtGui>
{
Q_OBJECT
public:
{
model->setReadOnly( false );
tree->setModel( model );
tree
->setRootIndex
( model
->index
( QString( "/home/randy" ) ) );
model1->setReadOnly( false );
righttree->setModel( model1 );
righttree
->setRootIndex
( model1
->index
( QString( "/tmp" ) ) );
tree->setDragEnabled( true );
tree->setAcceptDrops( true );
tree->setDropIndicatorShown( true );
tree->setDragDropOverwriteMode( false );
righttree->setDragEnabled( true );
righttree->setAcceptDrops( true );
righttree->setDropIndicatorShown( true );
righttree->setDragDropOverwriteMode( false );
splitter->addWidget( tree );
splitter->addWidget( righttree );
//QObject::connect( model, SIGNAL( layoutChanged( ) ), this, SLOT( refreshleft( ) ) );
//QObject::connect( model1, SIGNAL( layoutChanged( ) ), this, SLOT( refreshright( ) ) );
QObject::connect( timer,
SIGNAL( timeout
( ) ),
this,
SLOT( refreshleft
( ) ) );
QObject::connect( timer,
SIGNAL( timeout
( ) ),
this,
SLOT( refreshright
( ) ) );
setCentralWidget( splitter );
timer->start( 1000 );
}
private slots:
void refreshleft ()
{
model->refresh( tree->rootIndex() );
}
void refreshright ()
{
model1->refresh( righttree->rootIndex() );
}
private:
};
int main( int argc, char *argv[] )
{
// a "file manager" at simplest :)
MainWindow window;
window.show();
return a.exec( );
}
#include "app.moc"
#include <QtGui>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0 ) : QMainWindow( parent)
{
splitter = new QSplitter( this );
model = new QDirModel( this );
model->setReadOnly( false );
tree = new QTreeView;
tree->setModel( model );
tree->setRootIndex( model->index( QString( "/home/randy" ) ) );
model1 = new QDirModel( this );
model1->setReadOnly( false );
righttree = new QTreeView;
righttree->setModel( model1 );
righttree->setRootIndex( model1->index( QString( "/tmp" ) ) );
tree->setDragEnabled( true );
tree->setAcceptDrops( true );
tree->setDropIndicatorShown( true );
tree->setDragDropOverwriteMode( false );
righttree->setDragEnabled( true );
righttree->setAcceptDrops( true );
righttree->setDropIndicatorShown( true );
righttree->setDragDropOverwriteMode( false );
splitter->addWidget( tree );
splitter->addWidget( righttree );
timer = new QTimer( this );
//QObject::connect( model, SIGNAL( layoutChanged( ) ), this, SLOT( refreshleft( ) ) );
//QObject::connect( model1, SIGNAL( layoutChanged( ) ), this, SLOT( refreshright( ) ) );
QObject::connect( timer, SIGNAL( timeout( ) ), this, SLOT( refreshleft( ) ) );
QObject::connect( timer, SIGNAL( timeout( ) ), this, SLOT( refreshright( ) ) );
setCentralWidget( splitter );
timer->start( 1000 );
}
private slots:
void refreshleft ()
{
model->refresh( tree->rootIndex() );
}
void refreshright ()
{
model1->refresh( righttree->rootIndex() );
}
private:
QSplitter *splitter;
QDirModel *model;
QTreeView *tree;
QDirModel *model1;
QTreeView *righttree;
QTimer *timer;
};
int main( int argc, char *argv[] )
{
// a "file manager" at simplest :)
QApplication a( argc, argv );
MainWindow window;
window.show();
return a.exec( );
}
#include "app.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks