#include <QApplication>
#include <QtDebug>
#include <QtCore>
#include <QtGui>
int main(int argc, char** argv)
{
sp->addWidget(listView1);
sp->addWidget(listView2);
music1->setData("Some datails", Qt::UserRole);
qDebug()<<model.data(model.index(0,0).child(0,0), Qt::UserRole);
group1->appendRow(music1);
model.appendRow(group1);
qDebug()<<model.data(model.index(1,0).child(0,0), Qt::UserRole);
group2->appendRow(music2);
model.appendRow(group2);
listView1->setModel(&model);
listView2->setModel(&model);
QObject::connect(listView1,
SIGNAL(clicked
(const QModelIndex
&)),
listView2, SLOT(setRootIndex(const QModelIndex&)));
window.setCentralWidget(sp);
window.show();
return app.exec();
}
#include <QApplication>
#include <QtDebug>
#include <QtCore>
#include <QtGui>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QMainWindow window;
QSplitter *sp=new QSplitter;
QListView *listView1=new QListView;
QListView *listView2=new QListView;
sp->addWidget(listView1);
sp->addWidget(listView2);
QStandardItemModel model;
QStandardItem *group1 = new QStandardItem("Music Group 1");
QStandardItem *music1=new QStandardItem("Music 1");
music1->setData("Some datails", Qt::UserRole);
qDebug()<<model.data(model.index(0,0).child(0,0), Qt::UserRole);
group1->appendRow(music1);
model.appendRow(group1);
QStandardItem *group2 = new QStandardItem("Music Group 2");
QStandardItem *music2=new QStandardItem("Music 2");
qDebug()<<model.data(model.index(1,0).child(0,0), Qt::UserRole);
group2->appendRow(music2);
model.appendRow(group2);
listView1->setModel(&model);
listView1->setRootIndex(QModelIndex());
listView2->setModel(&model);
QObject::connect(listView1, SIGNAL(clicked(const QModelIndex&)),
listView2, SLOT(setRootIndex(const QModelIndex&)));
window.setCentralWidget(sp);
window.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks