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


C++ QListWidget::item方法代码示例

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


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

示例1:

dmz::V8Value
dmz::JsModuleUiV8QtBasic::_list_widget_item (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QListWidget *lw = self->v8_to_qobject<QListWidget> (Args.This ());
      if (lw) {

         if (Args.Length ()) {

            QListWidgetItem *item = lw->item (v8_to_int32 (Args[0]));
            if (item) {

               result = self->create_v8_qlistwidgetitem (item);
            }
         }
      }
   }

   return scope.Close (result);
}
开发者ID:rharder,项目名称:js,代码行数:25,代码来源:dmzJsModuleUiV8QtBasicListWidget.cpp

示例2: RemoveFilter

void OBSBasicFilters::RemoveFilter(OBSSource filter)
{
	uint32_t flags = obs_source_get_output_flags(filter);
	bool async = (flags & OBS_SOURCE_ASYNC) != 0;
	QListWidget *list = async ? ui->asyncFilters : ui->effectFilters;

	for (int i = 0; i < list->count(); i++) {
		QListWidgetItem *item = list->item(i);
		QVariant v = item->data(Qt::UserRole);
		OBSSource curFilter = v.value<OBSSource>();

		if (filter == curFilter) {
			DeleteListItem(list, item);
			break;
		}
	}

	const char *filterName = obs_source_get_name(filter);
	const char *sourceName = obs_source_get_name(source);
	if (!sourceName || !filterName)
		return;

	const char *filterId = obs_source_get_id(filter);

	blog(LOG_INFO, "User removed filter '%s' (%s) from source '%s'",
			filterName, filterId, sourceName);

	main->SaveProject();
}
开发者ID:chaturbatecom,项目名称:obs-studio,代码行数:29,代码来源:window-basic-filters.cpp

示例3: undo

void HistoryLog::undo()
{
	int size = ui->HistoryLogList->count();
	if(size > 0)
	{
		QString last = historyLog.back();
		QListWidgetItem* it = ui->HistoryLogList->takeItem(size-1);
		delete it;
		QStringList pieces = last.split( ":" );
		QString itemPiece = pieces[0].mid(0,pieces[0].count()-4).trimmed();
		QString fromPiece = pieces[1].mid(0,pieces[1].count()-4).trimmed();
		QString toPiece = pieces[2].trimmed();
		QListWidget* from = findWidgetByName(fromPiece);
		QListWidget* to = findWidgetByName(toPiece);
		QListWidgetItem* item;
		for(int idx = 0; idx< to->count(); idx++)
		{
			if(to->item(idx)->text() == itemPiece)
			{
				item = to->takeItem(idx);
				from->addItem(item);
				break;
			}
		}
		historyLog.erase(historyLog.end()-1);
	}
}
开发者ID:FrankZZ,项目名称:AvanScrum,代码行数:27,代码来源:HistoryLog.cpp

示例4: on_exportSavePushButton_clicked

void MainWindow::on_exportSavePushButton_clicked()
{
    QListWidget* savesList = findChild<QListWidget*>("vesselsInSaveListView");
    QTextEdit* savePathTextField = this->findChild<QTextEdit*>("SavePathTextEdit");
    QString pathToSave = savePathTextField->toPlainText();
    QFile saveFile(pathToSave);

    if(!saveFile.exists() || !pathToSave.endsWith(".sfs") || !saveFile.open(QIODevice::ReadOnly))
    {
        QMessageBox::warning(0, "Unable to open save file for writing", "When attempting to export new save, file was not opened.");
    }

    QString saveText(saveFile.readAll());
    std::size_t headerEnd = saveText.indexOf("VESSEL");
    QString header = saveText.left(headerEnd);
    saveFile.close();
    saveFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
    m_diagnosticsWindow->append(QString("Isolated header:\n") + header + QString("\n--Writing vessels to save--\n"));

    std::stringstream stringBuilder;

    for(int i = 0; i < savesList->count(); i++)
    {
        VesselListWidgetItem* item = (VesselListWidgetItem*)savesList->item(i);
        stringBuilder << item->GetVesselData()->AccessFullText()->toStdString();
    }

    stringBuilder << "}\n}";
    saveFile.write(header.toLocal8Bit());
    saveFile.write(stringBuilder.str().c_str());
    saveFile.close();

}
开发者ID:DaymareDev,项目名称:KSPS3,代码行数:33,代码来源:mainwindow.cpp

示例5: slotSetFormData

void PageItem::slotSetFormData()
{
    QTextEdit *textEdit = qobject_cast<QTextEdit*>(sender());
    if (textEdit) // textEdit == 0 if the above cast fails
    {
        slotSetFormData(textEdit->toPlainText());
        return;
    }
    QListWidget *listWidget = qobject_cast<QListWidget*>(sender());
    if (listWidget)
    {
        QList<int> choices;
        for (int i = 0; i < listWidget->count(); ++i)
        {
            if (listWidget->item(i)->isSelected())
                choices << i;
        }
        QString objectName = sender()->objectName();
        if (!objectName.startsWith(QLatin1String("PageItem::formField")))
            return;
        int which = objectName.remove(QLatin1String("PageItem::formField")).toInt();
        Poppler::FormFieldChoice *formField = static_cast<Poppler::FormFieldChoice*>(m_formFields.at(which).field);
        formField->setCurrentChoices(choices);
        return;
    }
}
开发者ID:damoguyan,项目名称:pdfviewer,代码行数:26,代码来源:pageitem.cpp

示例6: if

XtConnectPage::XtConnectPage(QWidget *parent, QSettings &s, ImapPage *imapPage): QWidget(parent), imap(imapPage)
{
    // Take care not to clash with the cache of the GUI
    QString cacheLocation = Common::writablePath(Common::LOCATION_CACHE) + QString::fromAscii("xtconnect-trojita");
    QFormLayout *layout = new QFormLayout(this);
    cacheDir = new QLineEdit(s.value(Common::SettingsNames::xtConnectCacheDirectory, cacheLocation).toString(), this);
    layout->addRow(tr("Cache Directory"), cacheDir);

    QGroupBox *box = new QGroupBox(tr("Mailboxes to synchronize"), this);
    QVBoxLayout *boxLayout = new QVBoxLayout(box);
    QListWidget *mailboxes = new QListWidget(box);
    mailboxes->addItems(s.value(Common::SettingsNames::xtSyncMailboxList).toStringList());
    for (int i = 0; i < mailboxes->count(); ++i) {
        mailboxes->item(i)->setFlags(Qt::ItemIsEnabled);
    }
    mailboxes->setToolTip(tr("Please use context menu inside the main application to select mailboxes to synchronize"));
    boxLayout->addWidget(mailboxes);
    layout->addRow(box);

    QString optionHost = s.value(Common::SettingsNames::xtDbHost).toString();
    int optionPort = s.value(Common::SettingsNames::xtDbPort, QVariant(5432)).toInt();
    QString optionDbname = s.value(Common::SettingsNames::xtDbDbName).toString();
    QString optionUsername = s.value(Common::SettingsNames::xtDbUser).toString();

    QStringList args = QCoreApplication::arguments();
    for (int i = 1; i < args.length(); i++) {
        if (args.at(i) == "-h" && args.length() > i)
            optionHost = args.at(++i);
        else if (args.at(i) == "-d" && args.length() > i)
            optionDbname = args.at(++i);
        else if (args.at(i) == "-p" && args.length() > i)
            optionPort = args.at(++i).toInt();
        else if (args.at(i) == "-U" && args.length() > i)
            optionUsername = args.at(++i);
    }


    hostName = new QLineEdit(optionHost);
    layout->addRow(tr("DB Hostname"), hostName);
    port = new QSpinBox();
    port->setRange(1, 65535);
    port->setValue(optionPort);
    layout->addRow(tr("DB Port"), port);
    dbName = new QLineEdit(optionDbname);
    layout->addRow(tr("DB Name"), dbName);
    username = new QLineEdit(optionUsername);
    layout->addRow(tr("DB Username"), username);

    imapPasswordWarning = new QLabel(tr("Please fill in all IMAP options, including the password, at the IMAP page. "
                                        "If you do not save the password, background synchronization will not run."), this);
    imapPasswordWarning->setWordWrap(true);
    imapPasswordWarning->setStyleSheet(SettingsDialog::warningStyleSheet);
    layout->addRow(imapPasswordWarning);
    debugLog = new QCheckBox();
    layout->addRow(tr("Debugging"), debugLog);

    QPushButton *btn = new QPushButton(tr("Run xTuple Synchronization"));
    connect(btn, SIGNAL(clicked()), this, SLOT(runXtConnect()));
    layout->addRow(btn);
}
开发者ID:G-shadow,项目名称:trojita,代码行数:60,代码来源:SettingsDialog.cpp

示例7:

void
PreferencesDialog::saveCommonList(QListWidget &from,
                                  QStringList &to) {
  to.clear();

  for (auto row = 0, numRows = from.count(); row < numRows; ++row)
    to << from.item(row)->data(Qt::UserRole).toString();
}
开发者ID:b2kguga,项目名称:mkvtoolnix,代码行数:8,代码来源:preferences_dialog.cpp

示例8: getOptions

bool KFFOpt_scenery::getOptions( QStringList & list )
{
	QListWidget* selected = ui_widget.selector_scenarii->selectedListWidget();
	QListWidgetItem* item;
	QString buffer;
	uint i = 0;

	item = selected->item( i );

	while ( item )
	{
		buffer.clear();
		buffer = buffer.setNum(i, 10);
		list << "--prop:sim/ai/scenario[" + buffer + "]=" + item->text();
		item = selected->item( ++i );
	}
	return true;
}
开发者ID:ac001,项目名称:ffs-central,代码行数:18,代码来源:opt_scenery.cpp

示例9: saveSettings

void KFFOpt_scenery::saveSettings()
{
	QListWidget* listWidget = ui_widget.selector_scenarii->selectedListWidget();
	QListWidgetItem* item;
	QStringList list;
	int i = 0;

	item = listWidget->item( i );

	while ( item )
	{
		list << item->text();
		item = listWidget->item( ++i );
	}

	Settings::setScenarii_selected( list );

	Settings::self()->writeConfig();
}
开发者ID:ac001,项目名称:ffs-central,代码行数:19,代码来源:opt_scenery.cpp

示例10: refreshDebugList

/*
 * When the timer (started in onDisplayMessage) fires, we update lst_debug with the
 * contents of debugListMessages.
 *
 * This happens in the timer event in order to rate limit it to a number of redraws per second
 * (redrawing, and especially scrolling the list view, can be quite resource intensive.)
 */
void MainWindow::refreshDebugList()
{
    QListWidget *lst = ui->lst_debug;
    while(lst->count() + debugListMessages.size() - scrollbackSize > 0 && lst->count() > 0) {
      delete lst->item(0);
    }
    lst->addItems(debugListMessages);
    debugListMessages.clear();
    lst->scrollToBottom();
}
开发者ID:dholth,项目名称:hairless-midiserial,代码行数:17,代码来源:mainwindow.cpp

示例11: updateKfi

void AnimationDialog::updateKfi(bool loop)
{
    m_kfi->deletePath();

    QListWidget *list = m_ui->listWidget;
    for(int i = 0; i < list->count(); i++)
    {
        AnimationListItem *item = static_cast<AnimationListItem*>(list->item(i));
        m_kfi->addKeyFrame(item->frame(), item->time());
    }
    m_kfi->setLoopInterpolation(loop);
}
开发者ID:Degot,项目名称:Las-Vegas-Reconstruction,代码行数:12,代码来源:AnimationDialog.cpp

示例12: setModelData

void MultiDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                   const QModelIndex &index) const
{
    QVariant value;

    QString  className = editor->metaObject()->className();
    if (className == "QTimeEdit") {
        QTimeEdit*  ed = qobject_cast<QTimeEdit*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->time());
    }
    else if (className == "QDateEdit") {
        QDateEdit*  ed = qobject_cast<QDateEdit*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->date());
    }
    else if (className == "QDateTimeEdit") {
        QDateTimeEdit*  ed = qobject_cast<QDateTimeEdit*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->dateTime());
    }
    else if (className == "IconViewer") {
        return;
    }
    else if (className == "QComboBox") {
        QComboBox*  ed = qobject_cast<QComboBox*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->currentText());
    }
    else if (className == "QListWidget") {
        QListWidget*  ed = qobject_cast<QListWidget*>(editor);
        Q_ASSERT( ed);
        QStringList  valList;
        int  itemCount = ed->count();
        for (int i = 0; i < itemCount; ++i) {
            QListWidgetItem*  bitItem = ed->item(i);
            bool  isChecked = (bitItem->checkState() == Qt::Checked);
            if (isChecked)
                valList += bitItem->text();
        }
        value = QVariant( valList);
    }
    else if (className == "QCheckBox") {
        QCheckBox*  ed = qobject_cast<QCheckBox*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->isChecked());
    }
    else {
        QItemDelegate::setModelData( editor, model, index);
        return;
    }
    model->setData(index, value, Qt::EditRole);
}
开发者ID:micwik,项目名称:ArnBrowser,代码行数:53,代码来源:MultiDelegate.cpp

示例13: btnDeleteClicked

void CQReportDefinition::btnDeleteClicked()
{
    QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentPage());

    QListWidgetItem * pNewSelection = NULL;

    int i, multipleSelection;

    for (i = pList->count() - 1, multipleSelection = 0; 0 <= i; i--)
        if (pList->item(i)->isSelected())
        {
            delete pList->takeItem(i);

            if (!pNewSelection && i < pList->count())
            {
                pNewSelection = pList->item(i); // We select the next.
            }

            multipleSelection++;
        }

    if (multipleSelection == 0) return; // Nothing selected,

    mChanged = true;
    pList->clearSelection();

    if (multipleSelection > 1) return;

    // Only one item was select and we move the selection to the next
    if (!pNewSelection && pList->count()) // We have removed item at the end.
        pNewSelection = pList->item(pList->count() - 1);

    // pNewSelection is NULL if the list is empty
    if (pNewSelection)
    {
        pNewSelection->setSelected(true);
    }

    return;
}
开发者ID:sachiinb,项目名称:COPASI,代码行数:40,代码来源:CQReportDefinition.cpp

示例14: GetFilter

inline OBSSource OBSBasicFilters::GetFilter(int row, bool async)
{
	if (row == -1)
		return OBSSource();

	QListWidget *list = async ? ui->asyncFilters : ui->effectFilters;
	QListWidgetItem *item = list->item(row);
	if (!item)
		return OBSSource();

	QVariant v = item->data(Qt::UserRole);
	return v.value<OBSSource>();
}
开发者ID:Kalreg,项目名称:obs-studio,代码行数:13,代码来源:window-basic-filters.cpp

示例15: addLocalContact

/**
 * Adds a Peer to the list of contacts, if it doesnt exist from before.
 * @brief MainWindow::addLocalContact
 * @param peer Peer to add
 * @return false if Peer already is in contact list, else true
 */
bool MainWindow::addLocalContact(Peer* peer)
{
    QListWidget* list =  ui->lstContacts;
    QString str(peer->getName() + "/" + peer->getIp());

    for (int i = 0; i < list->count(); ++i)
    {
        if (list->item(i)->data(Qt::DisplayRole).toString().compare(str) == 0) return false;
    }

    list->addItem(str);
    return true;
}
开发者ID:s176251,项目名称:cpp_prosjekt_2014,代码行数:19,代码来源:mainwindow.cpp


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