本文整理汇总了C++中QListWidget::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidget::count方法的具体用法?C++ QListWidget::count怎么用?C++ QListWidget::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidget
的用法示例。
在下文中一共展示了QListWidget::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: btnDownClicked
void CQReportDefinition::btnDownClicked()
{
QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentPage());
int i, imax, to, multipleSelection;
QListWidgetItem * pMove;
// Find the index of the first selected item.
for (i = 0, imax = pList->count(), to = -1, multipleSelection = 0; i < imax; i++)
if (pList->item(i)->isSelected())
{
if (multipleSelection == 0) to = i;
multipleSelection++;
}
else if (multipleSelection > 0)
{
pMove = pList->takeItem(i);
if (pMove)
{
pList->insertItem(to, pMove);
multipleSelection = 0;
mChanged = true;
}
}
// Unselect things we can not move.
for (i = pList->count() - multipleSelection, imax = pList->count(); i < imax; i++)
pList->item(i)->setSelected(false);
return;
}
示例2: 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();
}
示例3: selectNext
void AnimationDialog::selectNext()
{
m_kfi->stopInterpolation();
QListWidget* list = m_ui->listWidget;
int next = list->row(m_item) + 1;
if(next > list->count() - 1)
{
next = list->count() - 1;
}
AnimationListItem* item = static_cast<AnimationListItem*>(list->item(next));
list->setCurrentItem(item);
m_item = item;
m_parent->camera()->interpolateTo(m_item->frame(), 0.5);
}
示例4: filter
void AddPluginDialog::filter()
{
QListWidget* pluginList = ui->pluginList;
const int curr_item = 0 < pluginList->count() ? pluginList->currentRow() : 0;
pluginList->clear();
static QIcon fallIco = XdgIcon::fromTheme("preferences-plugin");
int pluginCount = mPlugins.length();
for (int i = 0; i < pluginCount; ++i)
{
const LxQt::PluginInfo &plugin = mPlugins.at(i);
QString s = QString("%1 %2 %3 %4").arg(plugin.name(),
plugin.comment(),
plugin.value("Name").toString(),
plugin.value("Comment").toString());
if (!s.contains(ui->searchEdit->text(), Qt::CaseInsensitive))
continue;
QListWidgetItem* item = new QListWidgetItem(ui->pluginList);
item->setText(QString("<b>%1</b><br>\n%2\n").arg(plugin.name(), plugin.comment()));
item->setIcon(plugin.icon(fallIco));
item->setData(INDEX_ROLE, i);
}
if (pluginCount > 0)
ui->pluginList->setCurrentRow(curr_item < pluginCount ? curr_item : pluginCount - 1);
}
示例5: formChannelList
void MainWindow::formChannelList(){
if (m_availableChannelsQuery->getChannels().size() == 0 ) return;
else
{
m_availableChannels = m_availableChannelsQuery->getChannels();
}
m_subscribedChannels = m_subscribedChannelsQuery->getChannels();
QListWidget * listWidget = ui->channelsListWidget;
QListWidget * subscribedListWidget = ui->subscribedListWidget;
// Tab - channels
while(listWidget->count()>0)
{
listWidget->takeItem(0);
}
foreach (Channel s, m_availableChannels){
QListWidgetItem * item = new QListWidgetItem(s.getName());
if (isSubscribed(s.getName())){
item->setBackgroundColor(Qt::lightGray);
}
listWidget->addItem(item);
}
示例6: 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();
}
示例7: 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;
}
}
示例8: fillLists
void MainWindow::fillLists(DisplayData *display)
{
QListWidget* list;
unsigned char rowsCount = display->getRowCount();
if(font != nullptr)
for(int i=1;i<=4;i++)
{
switch(i)
{
case 1:list = listOfRows1;break;
case 2:list = listOfRows2;break;
case 3:list = listOfRows3;break;
case 4:list = listOfRows4;break;
}
if(rowsCount>=i)
{
list->clear();
for(int j=0;j<display->getCountOfLinesInRow(i-1);j++)
{
QString text = QString::number(j) + ")" + display->getLine(i-1,j)->getAsString(font);
list->addItem(text);
}
}
quint16 num = lcd->getCurrentLineNumber(i-1);
if(num<list->count()) list->setCurrentRow(num,QItemSelectionModel::SelectCurrent);
}
}
示例9: setEditorData
void OperationsDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
const QVariant value = index.data(Qt::EditRole);
if (value.type() == QVariant::StringList) {
QListWidget *lw = qobject_cast<QListWidget *>(editor);
const auto items = lw->findItems(index.data(Qt::DisplayRole).toString(), Qt::MatchExactly);
if (!items.empty())
lw->setCurrentItem(items.first());
else
lw->setCurrentItem(lw->item(0));
const int extraWidth = 25;
const int extraHeight = 6;
lw->setMinimumWidth(lw->sizeHintForColumn(0) + extraWidth);
// to prevent possible hiding bottom part of the list
const int h = lw->count() * (lw->visualItemRect(lw->currentItem()).height() + extraHeight);
const int y = (lw->parentWidget() && (lw->parentWidget()->rect().bottom() < lw->y() + h))
? lw->parentWidget()->rect().bottom() - h - extraHeight : lw->y();
lw->setGeometry(lw->x(), y, lw->width(), h);
// now lw can be partially hidden behind the tree view
// if tree view has small rect, so set parent of lw
// to app window and map coordinates accordingly to leave lw in place
const auto globalCoord = lw->parentWidget()->mapToGlobal(lw->geometry().topLeft());
lw->setParent(appWindow);
const auto newLocalCoord = appWindow->mapFromGlobal(globalCoord);
lw->setGeometry(newLocalCoord.x(), newLocalCoord.y(), lw->width(), h);
}
else // single value
QStyledItemDelegate::setEditorData(editor, index);
}
示例10: 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);
}
示例11: 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);
}
}
示例12: 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();
}
示例13: strDelete
void MainWindow::strDelete(unsigned char strNum)
{
QListWidget* list;
list = nullptr;
switch(strNum)
{
case 1:list = listOfRows1;break;
case 2:list = listOfRows2;break;
case 3:list = listOfRows3;break;
case 4:list = listOfRows4;break;
}
if(list != nullptr)
{
int i = list->currentRow();
if(list->count()>=2)
{
if(i!=0) lcd->setLineNumber(strNum-1,i-1);
else lcd->setLineNumber(strNum-1,i);
lcd->getData()->deleteLine(strNum-1,i);
lcd->setPos(0,strNum-1);
display->update();
fillLists(lcd->getData());
}
else QMessageBox::warning(this,"Недопустимая операция","Невозможно удалить последнюю строку");
}
}
示例14: shouldClearListBeforeToAddNew
void PotentialPhishingDetailWidgetTest::shouldClearListBeforeToAddNew()
{
PotentialPhishingDetailWidget dlg;
QListWidget *listWidget = dlg.findChild<QListWidget *>(QStringLiteral("list_widget"));
QStringList lst;
lst << QStringLiteral("bla");
lst << QStringLiteral("bli");
lst << QStringLiteral("blo");
dlg.fillList(lst);
QCOMPARE(listWidget->count(), lst.count());
lst.clear();
lst << QStringLiteral("bla");
lst << QStringLiteral("bli");
dlg.fillList(lst);
QCOMPARE(listWidget->count(), lst.count());
}
示例15:
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();
}