Main::Main() : QMainWindow() { QWidget *main = new QWidget (this); setCentralWidget(main); QVBoxLayout *layout = new QVBoxLayout; QListView *all = new QListView; all->setModelColumn(UPnPDeviceModel::DeviceRoleFriendlyName); all->setModel(UPnPDeviceModel::getDefault()); QListView *server = new QListView; server->setModel(new UPnPServerModel ()); server->setModelColumn(UPnPDeviceModel::DeviceRoleFriendlyName); connect (server, SIGNAL(activated(QModelIndex)), SLOT(onRowActivated(QModelIndex))); QListView *renderer = new QListView; renderer->setModel(new UPnPRendererModel ()); renderer->setModelColumn(UPnPDeviceModel::DeviceRoleFriendlyName); m_browser = new QListView; layout->addWidget(new QLabel(QString::fromLatin1("All devices"), main)); layout->addWidget(all); layout->addWidget(new QLabel(QString::fromLatin1("UPnP servers"), main)); layout->addWidget(server); layout->addWidget(new QLabel(QString::fromLatin1("UPnP renderer"), main)); layout->addWidget(renderer); layout->addWidget(new QLabel(QLatin1String("Browse test"), main)); layout->addWidget(m_browser); main->setLayout(layout); }
int main( int argc, char* argv[] ){ if(argc != 2){ return std::cerr<<"No!"<<std::endl; } QApplication a(argc,argv); std::ifstream file; file.open(argv[1]); std::string line; std::string alltext; while(getline(file, line)){ alltext += line; alltext += "\n"; } file.close(); QString filetext(QString::fromStdString(alltext)); DnDAddressModel model(filetext); QListView listView; listView.setModel(&model); listView.setModelColumn(0); listView.show(); QTreeView treeView; treeView.setModel(&model); treeView.show(); QTableView tableView; tableView.setModel(&model); tableView.show(); return a.exec(); }
int main( int argc, char* argv[] ) { QApplication app( argc, argv ); // Open the addressbook file in the working directory QFile file("addressbook.csv"); if ( !file.open(QIODevice::ReadOnly|QIODevice::Text) ) return 1; // Read its content into a string QString addresses = QString::fromUtf8(file.readAll()); AddressbookModel model(addresses); QListView listView; listView.setModel(&model); listView.setModelColumn(0); listView.show(); QTreeView treeView; treeView.setModel(&model); treeView.show(); QTableView tableView; tableView.setModel(&model); tableView.show(); return app.exec(); }
/*! Returns the popup used to display completions. \sa setPopup() */ QAbstractItemView *QCompleter::popup() const { Q_D(const QCompleter); #ifndef QT_NO_LISTVIEW if (!d->popup && completionMode() != QCompleter::InlineCompletion) { QListView *listView = new QListView; listView->setEditTriggers(QAbstractItemView::NoEditTriggers); listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); listView->setSelectionBehavior(QAbstractItemView::SelectRows); listView->setSelectionMode(QAbstractItemView::SingleSelection); listView->setModelColumn(d->column); QCompleter *that = const_cast<QCompleter*>(this); that->setPopup(listView); } #endif // QT_NO_LISTVIEW return d->popup; }