//! [0]
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

// Unindented for quoting purposes:
//! [1]
QStringList numbers;
numbers << "One" << "Two" << "Three" << "Four" << "Five";

QAbstractItemModel *model = new StringListModel(numbers);
//! [0] //! [1] //! [2] //! [3]
QListView *view = new QListView;
//! [2]
view->setWindowTitle("View onto a string list model");
//! [4]
view->setModel(model);
//! [3] //! [4]

    model->insertRows(5, 7, QModelIndex());

    for (int row = 5; row < 12; ++row) {
        QModelIndex index = model->index(row, 0, QModelIndex());
        model->setData(index, QString::number(row+1));
    }

//! [5]
    view->show();
    return app.exec();
}
예제 #2
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QObject *parent = &app;

    QStringList numbers;
    numbers << "One" << "Two" << "Three" << "Four" << "Five";

    QAbstractItemModel *stringListModel = new QStringListModel(numbers, parent);

//! [0]
    QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(parent);
    filterModel->setSourceModel(stringListModel);
//! [0]

    QWidget *window = new QWidget;

//! [1]
    QListView *filteredView = new QListView;
    filteredView->setModel(filterModel);
//! [1]
    filteredView->setWindowTitle("Filtered view onto a string list model");

    QLineEdit *patternEditor = new QLineEdit;
    QObject::
    connect(patternEditor, SIGNAL(textChanged(const QString &)),
            filterModel, SLOT(setFilterRegExp(const QString &)));

    QVBoxLayout *layout = new QVBoxLayout(window);
    layout->addWidget(filteredView);
    layout->addWidget(patternEditor);

    window->show();
    return app.exec();
}
예제 #3
0
int main( int argc, char** argv ) {
    QApplication app( argc, argv );


    CityEngine *engine = new CityEngine(QCoreApplication::instance());
    CityTableModel *model = new CityTableModel(QCoreApplication::instance());
    model->setInput(engine);
    QListView* list = new QListView;
    list->setModel( model );
    list->setWindowTitle( "QListView" );
    list->show();

    QTreeView* tree = new QTreeView;
    tree->setModel( model );
    tree->setWindowTitle( "QTreeView" );
    tree->show();

    QTableView* table = new QTableView;
    table->setModel( model );
    table->setWindowTitle( "QTableView" );
    table->show();

    return app.exec();
}
예제 #4
0
파일: main.cpp 프로젝트: dtbinh/dviz
int main(int argc, char **argv)
{
	QApplication app(argc, argv);		
	//QCoreApplication app(argc, argv);
	
	if(0)
	{
		ImageRecord rec("foobar.jpg");
		rec.setImageId("abc");
		ImageRecord::addRecord(&rec);
		qDebug() << "New Record:"<<rec;
		
		ImageRecord * rec2 = ImageRecord::retrieveImageId("abc");
		qDebug() << "Record 'ABC':"<<rec2;
	}
	else
	if(0)
	{
		QListView * lv = new QListView;
		lv->setWindowTitle(IMAGEDB_FILE);
		lv->setModel(ImageRecordListModel::instance());
		lv->show();
	}
	else
	{
		ImageRecord * rec = ImageRecord::retrieve(99);
		//rec->setFile("test.jpg");
		qDebug() << "Record#1: "<<rec;
	}

// 	ImageRecord::db().close();
	
	
 	return -1;
	return app.exec();
}