当前位置: 首页>>代码示例>>C++>>正文


C++ QListView::show方法代码示例

本文整理汇总了C++中QListView::show方法的典型用法代码示例。如果您正苦于以下问题:C++ QListView::show方法的具体用法?C++ QListView::show怎么用?C++ QListView::show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QListView的用法示例。


在下文中一共展示了QListView::show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

      QListView *listView = new QListView;
      QListView *newListView = new QListView;
      QStringList nameItem;
        nameItem << "Linux" << "Android" << "Mac OS";

      QStandardItemModel *model = new QStandardItemModel(nameItem.length(),1); // initialize row and columns of data model
        for(int i = 0; i < model->rowCount(); ++i)
          {
            QModelIndex modelIndex = model->index(i,0);
            QString str = nameItem.at(i);
              model->setData(modelIndex,str,Qt::DisplayRole);
              model->setData(modelIndex,"ToolTip for" + str,Qt::ToolTipRole);
              model->setData(modelIndex,QIcon(":/Images/" + str + ".jpeg"),Qt::DecorationRole);
          }

        listView->setViewMode(QListView::IconMode);
        listView->setModel(model);
        listView->setGeometry(430,340,200,200);
          newListView->setViewMode(QListView::IconMode);
          newListView->setModel(model);
          newListView->setGeometry(listView->geometry());
      listView->show();
      newListView->show();



    return a.exec();
}
开发者ID:DenisLaky,项目名称:QtProjects,代码行数:32,代码来源:main.cpp

示例2: QStandardItem

void tst_QItemDelegate::task257859_finalizeEdit()
{
    QStandardItemModel model;
    model.appendRow(new QStandardItem());

    QListView view;
    view.setModel(&model);
    view.show();
    QApplication::setActiveWindow(&view);
    view.setFocus();
    QTest::qWait(30);

    QModelIndex index = model.index(0, 0);
    view.edit(index);
    QTest::qWait(30);

    QList<QLineEdit *> lineEditors = qFindChildren<QLineEdit *>(view.viewport());
    QCOMPARE(lineEditors.count(), 1);

    QPointer<QWidget> editor = lineEditors.at(0);
    QCOMPARE(editor->hasFocus(), true);

    QDialog dialog;
    QTimer::singleShot(500, &dialog, SLOT(close()));
    dialog.exec();
    QTRY_VERIFY(!editor);
}
开发者ID:redanium,项目名称:qt,代码行数:27,代码来源:tst_qitemdelegate.cpp

示例3: doubleEditorNegativeInput

void tst_QItemDelegate::doubleEditorNegativeInput()
{
    QStandardItemModel model;

    QStandardItem *item = new QStandardItem;
    item->setData(10.0, Qt::DisplayRole);
    model.appendRow(item);

    QListView view;
    view.setModel(&model);
    view.show();

    QModelIndex index = model.index(0, 0);
    view.setCurrentIndex(index); // the editor will only selectAll on the current index
    view.edit(index);

    QList<QDoubleSpinBox*> editors = qFindChildren<QDoubleSpinBox *>(view.viewport());
    QCOMPARE(editors.count(), 1);

    QDoubleSpinBox *editor = editors.at(0);
    QCOMPARE(editor->value(), double(10));

    QTest::keyClick(editor, Qt::Key_Minus);
    QTest::keyClick(editor, Qt::Key_1);
    QTest::keyClick(editor, Qt::Key_0);
    QTest::keyClick(editor, Qt::Key_Comma); //support both , and . locales
    QTest::keyClick(editor, Qt::Key_Period);
    QTest::keyClick(editor, Qt::Key_0);
    QTest::keyClick(editor, Qt::Key_Enter);
    QApplication::processEvents();

    QCOMPARE(index.data().toString(), QString("-10"));
}
开发者ID:redanium,项目名称:qt,代码行数:33,代码来源:tst_qitemdelegate.cpp

示例4: buildFileBrowser

void MainWindow::buildFileBrowser()
{
    QString rootPath = qgetenv("HOME");
    this->drivesModel->setFilter(QDir::NoDotAndDotDot | QDir::Dirs);

    QTreeView *treeView = this->treeView = new QTreeView(this->ui->dockDir);
    treeView->setModel(this->drivesModel);
    treeView->setRootIndex(this->drivesModel->setRootPath(rootPath + "/../"));
    treeView->hideColumn(1);
    treeView->hideColumn(2);
    treeView->hideColumn(3);
    treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    treeView->setDragEnabled(true);
    treeView->setDragDropMode(QAbstractItemView::DragOnly);
    this->ui->dockDir->setWidget(treeView);

    this->filesModel->setFilter(QDir::NoDotAndDotDot | QDir::Files);
    QListView *listView = this->listView = new QListView(this->ui->dockFile);
    listView->setModel(this->filesModel);
    listView->setRootIndex(this->filesModel->setRootPath(rootPath));
    listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    listView->setDragEnabled(true);
    listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
    this->ui->dockFile->setWidget(listView);

    listView->show();
    treeView->show();
}
开发者ID:derselbst,项目名称:ANMP,代码行数:28,代码来源:mainwindow.cpp

示例5: main

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();
}
开发者ID:apregoe,项目名称:qtPractice,代码行数:35,代码来源:main.cpp

示例6: main

//! [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();
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:30,代码来源:main.cpp

示例7: main

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();
}
开发者ID:asieriko,项目名称:custommodel,代码行数:28,代码来源:main.cpp

示例8: editorKeyPress

void tst_QItemDelegate::editorKeyPress()
{
    QFETCH(QString, initial);
    QFETCH(QString, expected);

    QStandardItemModel model;
    model.appendRow(new QStandardItem(initial));

    QListView view;
    view.setModel(&model);
    view.show();

    QModelIndex index = model.index(0, 0);
    view.setCurrentIndex(index); // the editor will only selectAll on the current index
    view.edit(index);

    QList<QLineEdit*> lineEditors = qFindChildren<QLineEdit *>(view.viewport());
    QCOMPARE(lineEditors.count(), 1);

    QLineEdit *editor = lineEditors.at(0);
    QCOMPARE(editor->selectedText(), initial);

    QTest::keyClicks(editor, expected);
    QTest::keyClick(editor, Qt::Key_Enter);
    QApplication::processEvents();

    QCOMPARE(index.data().toString(), expected);
}
开发者ID:redanium,项目名称:qt,代码行数:28,代码来源:tst_qitemdelegate.cpp

示例9: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    // 创建文件系统模型
    QFileSystemModel model;
    // 指定要监视的目录
    model.setRootPath(QDir::currentPath());

    // 创建树型视图
    QTreeView tree;
    // 为视图指定模型
    tree.setModel(&model);
    // 指定根索引
    tree.setRootIndex(model.index(QDir::currentPath()));

    // 创建列表视图
    QListView list;
    list.setModel(&model);
    list.setRootIndex(model.index(QDir::currentPath()));

    tree.show();
    list.show();

    return app.exec();
}
开发者ID:ifhw,项目名称:study,代码行数:25,代码来源:main.cpp

示例10: main

int main(int c, char **v)
{
    QApplication a(c, v);

    QListView view;
    view.setUniformItemSizes(true);
    view.setModel(new RandomListModel(&view));
    view.show();

    return a.exec();
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:11,代码来源:main.cpp

示例11: setWindowIcon

MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow){
    ui->setupUi(this);
    setWindowIcon(QIcon("/Users/nick102795/Desktop/favicon.ico"));
    // build all initial backend structures & load the appropriate data from files
    setInitialState();
    // Set Up the top 8 Most Popular Playlists
    QListView *listView = ui->mostPopularPlaylistListView;
    QAbstractItemModel *model = buildModel();   // make the buildModel() func to intake the new most-popular PL strings
    listView->setModel(model);
    listView->show();
}
开发者ID:pvelarde,项目名称:playlist,代码行数:11,代码来源:mainwindow.cpp

示例12: main

int main( int argc, char **argv )
{
    QApplication app( argc, argv );

    IntModel model( 25 );

    QListView list;
    list.setModel( &model );
    list.show();

    return app.exec();
}
开发者ID:embicoin,项目名称:Foundations.of.Qt.Development,代码行数:12,代码来源:main.cpp

示例13: main

int main(int argc, char* argv[])
{
  QApplication app(argc, argv);
  QStringListModel model;
  QStringList toBuy;
  toBuy << "butter" << "milk" 
       << "cherries" << "bananas";
  model.setStringList(toBuy);
  QListView view;
  view.setModel(&model);
  view.show();
  return app.exec();
}
开发者ID:bingo2011,项目名称:codes_TheBookOfQT4,代码行数:13,代码来源:main.cpp

示例14: main

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    app.setOrganizationName("CuteRadio");
    app.setApplicationName("Genres");

    CuteRadio::GenresModel model;

    QListView view;
    view.setModel(&model);
    view.setMinimumSize(QSize(500, 500));

    model.reload();

    view.show();

    return app.exec();
}
开发者ID:marxoft,项目名称:libcuteradio,代码行数:17,代码来源:main.cpp

示例15: if

// single playlist adding
void MainWindow::on_pushButton_3_clicked(){
    ui->textEdit_3->setStyleSheet("color:black; background-color:white");
    playlistName = ui->textEdit_3->toPlainText();
    playlistPopularity = ui->textEdit_4->toPlainText();
    string sPlaylistName = playlistName.toLatin1().data();
    string sPlaylistPopularity = playlistPopularity.toLatin1().data();
    //test single playlist input: Friend Of God, Your Great Name, Collide, September 63

    bool is_legal_pop = true;
    bool is_legal_ss = is_legal_input_str_stream(sPlaylistName);
    int dec = playlistPopularity.toInt(&is_legal_pop, 10);

    // some general console error logs
    if(!is_legal_ss && !is_legal_pop){
        std::cout << "illegal stream & illegal popularity inputs" << std::endl;
    }
    else if(!is_legal_ss){
        std::cout << "illegal stream input" << std::endl;
    }
    else if(!is_legal_pop){
        std::cout << "illegal popularity input" << std::endl;
    }

    if(is_legal_ss && is_legal_pop){
        string song_id_stream = convTitleStream2StrNumStream(sPlaylistName);
        std::cout << "Single Playlist Submitted: " << (sPlaylistName + " " + sPlaylistPopularity) << std::endl;

        Playlist* new_pl = new Playlist(song_id_stream,playlistPopularity.toInt());
        // add a new playlist
        pl_c->add(new_pl);

        // add this playlists popularity to the song's pop
        for(int ii = 0; ii < new_pl->my_songs->size(); ii++){
            std::string member_song_id = new_pl->my_songs->at(ii);
            // sng_c->query(member_song_id)->set_song_popularity(sng_c->query(member_song_id)->getPopularity() + new_pl->getPopularity());
            sng_c->query((member_song_id))->song_add_playlist(new_pl->my_id);
        }

        // refine is required to maintain the backend storage and so-on
        pl_c->refine();
        QListView *listView = ui->mostPopularPlaylistListView;
        QAbstractItemModel *model = buildModel();   // make the buildModel() func to intake the new most-popular PL strings
        listView->setModel(model);
        listView->show();
    }
}
开发者ID:pvelarde,项目名称:playlist,代码行数:47,代码来源:mainwindow.cpp


注:本文中的QListView::show方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。