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


C++ QListView类代码示例

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


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

示例1: prepareProjectListView

void MainWindow::prepareProjectListView()
{
    QListView *view = ui->centralWidget->findChild<QListView*>("projectLst");
    QStandardItemModel *model = new QStandardItemModel;
    view->setItemDelegate(new ProjectItemDelegate);
    view->setModel(model);
}
开发者ID:humbhenri,项目名称:TimeTracker,代码行数:7,代码来源:mainwindow.cpp

示例2: GraphicalArray

void GraphicalArrayTest::test_removeItems()
{
  GraphicalArray * value = new GraphicalArray();
  QPushButton * button = findRemoveButton(value);
  QStringListModel * model = findModel(value);
  QListView * view = findListView(value);
  QItemSelectionModel::SelectionFlags flag = QItemSelectionModel::Select;

  model->setStringList( QStringList() << "Hello" << "World" << "and" << "Happy" << "New" << "Year!" );
  value->show();

  view->selectionModel()->select( model->index(0), flag ); // select "Hello"
  view->selectionModel()->select( model->index(1), flag ); // select "World"
  view->selectionModel()->select( model->index(3), flag ); // select "Happy"
  view->selectionModel()->select( model->index(5), flag ); // select "Year"

  // simulate a click on the 'Remove' button
  QTest::mouseClick( button, Qt::LeftButton );

  QStringList values = model->stringList();

  QCOMPARE( values.count(), 2 );
  QCOMPARE( values.at(0), QString("and") );
  QCOMPARE( values.at(1), QString("New") );

  delete value;
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例3: stylefile

QComboBox* FilterButton::createComboBox(const QStringList& options, const QString& currentOption)
{
	// Stylesheet
	QFile stylefile(":/qss/filterbutton.qss"); stylefile.open(QFile::ReadOnly);
	QString stylesheet(stylefile.readAll());

	filtersComboBox = new QComboBox;

	QListView * listView = new QListView(filtersComboBox);
	filtersComboBox->addItems(options);
	listView->setStyleSheet(stylesheet);


	filtersComboBox->setView(listView);
	filtersComboBox->setStyleSheet(stylesheet);

	// Filter
	filtersComboBox->setCurrentIndex(options.indexOf(currentOption));

	// Connect the combobox's signal to our own
	connect(filtersComboBox, SIGNAL(currentIndexChanged(const QString&)),
			this, SIGNAL(selectionChanged(const QString&)));

	return filtersComboBox;
}
开发者ID:jonongjs,项目名称:auv-vision-system,代码行数:25,代码来源:FilterButton.cpp

示例4: QDialog

PrivateChatDialog::PrivateChatDialog(QWidget * parent)
    : QDialog(parent)
{
    m_name_w = new QLineEdit;

    m_owner_w = new QLineEdit;
    m_owner_w->setReadOnly(true);

    QListView * listView = new QListView;
    listView->setModel(&m_model);

    QFormLayout * formLayout = new QFormLayout;
    formLayout->addRow(tr("&Name : "), m_name_w);
    formLayout->addRow(tr("&Owner : "), m_owner_w);
    formLayout->addRow(tr("&Player : "), listView);

    m_buttonBox = new QDialogButtonBox;
    connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    QVBoxLayout * mainLayout = new QVBoxLayout;
    mainLayout->addLayout(formLayout);
    mainLayout->addWidget(m_buttonBox);

    setLayout(mainLayout);

    setSizeGripEnabled(true);
}
开发者ID:pit-le-rouge,项目名称:rolisteam,代码行数:28,代码来源:privatechatdialog.cpp

示例5: 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

示例6: slotDeleteSelected

void VegetationWidget::slotDeleteSelected()
{
	QListView* view = qobject_cast<QListView*>(sender());
	QStandardItemModel* model = qobject_cast<QStandardItemModel*>(view->model());
	QString dirString("");
	if (view == _treeListView)
	{
		std::string plantDir = g_SystemContext._workContextDir;
		plantDir.append(CONTEXT_DIR);
		plantDir.append("/Plant/");
		dirString = chineseTextUTF8ToQString(plantDir + "Tree/");
	}
	else
	{
		std::string plantDir = g_SystemContext._workContextDir;
		plantDir.append(CONTEXT_DIR);
		plantDir.append("/Plant/");
		dirString = chineseTextUTF8ToQString(plantDir + "Grass/");
	}
	QItemSelectionModel* selectionModel = view->selectionModel();
	QModelIndexList	modelList = selectionModel->selectedIndexes();
	if (modelList.size() < 1)
		return;
	for (int i = 0; i < modelList.size(); ++i)
	{
		QStandardItem* everyItem = model->itemFromIndex(modelList.at(i));
		QFile::remove(dirString + everyItem->text());
		int row = everyItem->row();
		model->removeRow(row);
	}
}
开发者ID:FreeDegree,项目名称:Zhang,代码行数:31,代码来源:PlantBrushDockWidget.cpp

示例7: getBookListDialog

void MainWindow::addBook()
{
    //Multiselection file dialog
    //http://www.qtcentre.org/threads/34226-QFileDialog-select-multiple-directories?p=220108#post220108
    QFileDialog getBookListDialog(this,"Choose Book to Convert",lastSelectDir);
    getBookListDialog.setFileMode(QFileDialog::DirectoryOnly);
    getBookListDialog.setOption(QFileDialog::DontUseNativeDialog,true);

    QListView *l = getBookListDialog.findChild<QListView*>("listView");
    if (l)
    {
        l->setSelectionMode(QAbstractItemView::ExtendedSelection);
    }

    QTreeView *t = getBookListDialog.findChild<QTreeView*>("treeView");
    if (t)
    {
        t->setSelectionMode(QAbstractItemView::ExtendedSelection);
    }
    //

    if(getBookListDialog.exec() == QDialog::Accepted)
    {
        ui->listWidget->addItems(getBookListDialog.selectedFiles());
    }
    this->lastSelectDir = getBookListDialog.directory().absolutePath();
}
开发者ID:diepdtnse03145,项目名称:Nook-HD-Manga-Converter,代码行数:27,代码来源:mainwindow.cpp

示例8: QMenu

MainWindow::MainWindow()
{
    QMenu *fileMenu = new QMenu(tr("&File"));

    QAction *quitAction = fileMenu->addAction(tr("E&xit"));
    quitAction->setShortcut(tr("Ctrl+Q"));

    menuBar()->addMenu(fileMenu);

//  For convenient quoting:
//! [0]
QListView *listView = new QListView(this);
listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
listView->setDragEnabled(true);
listView->setAcceptDrops(true);
listView->setDropIndicatorShown(true);
//! [0]

    this->listView = listView;

    connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));

    setupListItems();

    setCentralWidget(listView);
    setWindowTitle(tr("List View"));
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:27,代码来源:mainwindow.cpp

示例9: background

void TransparentBg::backgroundUpdated()
{
    if (parent()->inherits("QTextEdit")){
        QTextEdit *text = static_cast<QTextEdit*>(parent());
        const QPixmap *pix = background(text->colorGroup().color(QColorGroup::Base));
        QPoint pp = text->viewportToContents(QPoint(0, 0));
        bgX = pp.x();
        bgY = pp.y();
        if ((pix == NULL) || pix->isNull()){
            if (text->paper().pixmap() && !text->paper().pixmap()->isNull()){
                text->setPaper(QBrush(text->colorGroup().base()));
                text->setStaticBackground(false);
            }
            return;
        }
        QPoint pp1 = text->topLevelWidget()->mapFromGlobal(text->mapToGlobal(QPoint(0, 0)));
        QPixmap bg(bgX + text->width(), bgY + text->height());
        QPainter p;
        p.begin(&bg);
        p.drawTiledPixmap(bgX, bgY, text->width(), text->height(), *pix, pp1.x(), pp1.y());
        p.end();
        text->setPaper(QBrush(text->colorGroup().background(), bg));
        text->setStaticBackground(true);
        text->setBackgroundMode(QWidget::NoBackground);
        text->viewport()->setBackgroundMode(QWidget::NoBackground);
        return;
    }
    if (parent()->inherits("QListView")){
        QListView *p = static_cast<QListView*>(parent());
        p->viewport()->repaint();
    }
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例10: main

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

示例11: HistoryCompletionModel

WebView *TabWidget::newTab(bool makeCurrent)
{
    // line edit
    UrlLineEdit *urlLineEdit = new UrlLineEdit;
    QLineEdit *lineEdit = urlLineEdit->lineEdit();
    if (!m_lineEditCompleter && count() > 0) {
        HistoryCompletionModel *completionModel = new HistoryCompletionModel(this);
        completionModel->setSourceModel(BrowserApplication::historyManager()->historyFilterModel());
        m_lineEditCompleter = new QCompleter(completionModel, this);
        // Should this be in Qt by default?
        QAbstractItemView *popup = m_lineEditCompleter->popup();
        QListView *listView = qobject_cast<QListView*>(popup);
        if (listView)
            listView->setUniformItemSizes(true);
    }
    lineEdit->setCompleter(m_lineEditCompleter);
    connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed()));
    m_lineEdits->addWidget(urlLineEdit);
    m_lineEdits->setSizePolicy(lineEdit->sizePolicy());

    // optimization to delay creating the more expensive WebView, history, etc
    if (count() == 0) {
        QWidget *emptyWidget = new QWidget;
        QPalette p = emptyWidget->palette();
        p.setColor(QPalette::Window, palette().color(QPalette::Base));
        emptyWidget->setPalette(p);
        emptyWidget->setAutoFillBackground(true);
        disconnect(this, SIGNAL(currentChanged(int)),
                   this, SLOT(currentChanged(int)));
        addTab(emptyWidget, tr("(Untitled)"));
        connect(this, SIGNAL(currentChanged(int)),
                this, SLOT(currentChanged(int)));
        currentChanged(currentIndex());
        return 0;
    }
开发者ID:KertyXP,项目名称:qt,代码行数:35,代码来源:tabwidget.cpp

示例12: syg_rozm_slot

void Rozmowa::syg_rozm_slot(int index)
{
    //this->index=index;
    QListView* rozmowa = this->findChild<QListView*>("rozmowa");
    QStringList list= model->messages[index];
    rozmowa->setModel(new QStringListModel(list));
}
开发者ID:Diamorotic,项目名称:SecuTalk,代码行数:7,代码来源:rozmowa.cpp

示例13: QWidget

Window::Window(QWidget *parent)
    : QWidget(parent)
{
    FileListModel *model = new FileListModel(this);
    model->setDirPath(QLibraryInfo::location(QLibraryInfo::PrefixPath));

    QLabel *label = new QLabel(tr("&Directory:"));
    QLineEdit *lineEdit = new QLineEdit;
    label->setBuddy(lineEdit);

    QListView *view = new QListView;
    view->setModel(model);

    logViewer = new QTextBrowser;
    logViewer->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));

    connect(lineEdit, SIGNAL(textChanged(QString)),
            model, SLOT(setDirPath(QString)));
    connect(lineEdit, SIGNAL(textChanged(QString)),
            logViewer, SLOT(clear()));
    connect(model, SIGNAL(numberPopulated(int)),
            this, SLOT(updateLog(int)));
    
    QGridLayout *layout = new QGridLayout;
    layout->addWidget(label, 0, 0);
    layout->addWidget(lineEdit, 0, 1);
    layout->addWidget(view, 1, 0, 1, 2);
    layout->addWidget(logViewer, 2, 0, 1, 2);

    setLayout(layout);
    setWindowTitle(tr("Fetch More Example"));
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:32,代码来源:window.cpp

示例14: listView

// Reimplemented 
void QmvItem::paintCell( QPainter *p, const QColorGroup &cg,
                                 int column, int width, int alignment )
{
    QListView *listview = listView();
    
    QColorGroup g( cg );
    g.setColor( QColorGroup::Base, backgroundColor() );
    g.setColor( QColorGroup::Foreground, Qt::black );
    g.setColor( QColorGroup::Text, Qt::black );
    
    int indent = 0;
    if ( column == 0 ) {
        indent = 20 + (shuttletupleattribute  ? 20 : 0 );
        p->fillRect( 0, 0, width, height(), backgroundColor() );
        p->save();
        p->translate( indent, 0 );
    }

    if ( isChanged() && column == 0 ) {
        p->save();
        QFont f = p->font();
        f.setBold( TRUE );
        p->setFont( f );
    }

    if ( !hasCustomContents() || column != 1 ) {
        QListViewItem::paintCell( p, g, column, width - indent, alignment  );
    } else {
        p->fillRect( 0, 0, width, height(), backgroundColor() );
        drawCustomContents( p, QRect( 0, 0, width, height() ) );
    }
    
    if ( isChanged() && column == 0 )
        p->restore();
    if ( column == 0 )
        p->restore();
        // Draw +/- open/close control icon on tuple items
    if ( !shuttletupleattribute && column == 0 ) {
        p->save();
        p->setPen( cg.foreground() );
        p->setBrush( cg.base() );
        p->drawRect( 5, height() / 2 - 4, 9, 9 );
        p->drawLine( 7, height() / 2, 11, height() / 2 );
        if ( !isOpen() )
            p->drawLine( 9, height() / 2 - 2, 9, height() / 2 + 2 );
        p->restore();
    }
    
    p->save();
    p->setPen( QPen( cg.dark(), 1 ) );
    p->drawLine( 0, height() - 1, width, height() - 1 );
    p->drawLine( width - 1, 0, width - 1, height() );
    p->restore();

    if ( listview->currentItem() == this && column == 0 &&
         !listview->hasFocus() && !listview->viewport()->hasFocus() )
        paintFocus( p, cg, QRect( 0, 0, width, height() ) );


}
开发者ID:py1668,项目名称:xpracman-qt2-final,代码行数:61,代码来源:qmvedit.cpp

示例15: QDialog

Rozmowa::Rozmowa(QWidget *parent, const QModelIndex& index, Model* mod ) :
    QDialog(parent),
    ui(new Ui::Rozmowa)
{
    ui->setupUi(this);
    message = this->findChild<QPlainTextEdit*>("wiadomosc");//message qplaintext wyslanie
    message->insertPlainText("");
    message->clear();
    QPushButton* send = this->findChild<QPushButton*>("send");
    model = mod;

    QModelIndex ind = model->index( index.row(), 0, QModelIndex() );
    //((MainWindow*)this->parent())->logged_user.numer;
    QVariant value = model->data( ind, Qt::DisplayRole).toString();
    QString title = value.toString();
    ind = model->index( index.row(), 2 );
    char numer[9];
    itoa(((MainWindow*)this->parent())->logged_user.numer,numer,10);
    title += " - (";
    //title += ind.data().toString();
    title += " moj numer: ";
    title += numer;
    title += ")";

    setWindowTitle(title);

    QListView* rozmowa = this->findChild<QListView*>("rozmowa");
    rozmowa->setModel(model);
    rozmowa->setRootIndex(index);

    connect(send, SIGNAL(clicked()), ((MainWindow*)this->parent())->socket, SLOT(send_text_message()));
    connect(this->model, SIGNAL(syg_rozm(int)),this,SLOT(syg_rozm_slot(int)));
}
开发者ID:Diamorotic,项目名称:SecuTalk,代码行数:33,代码来源:rozmowa.cpp


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