本文整理汇总了C++中QListWidget::currentItem方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidget::currentItem方法的具体用法?C++ QListWidget::currentItem怎么用?C++ QListWidget::currentItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidget
的用法示例。
在下文中一共展示了QListWidget::currentItem方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emitPluginSelected
void AddPluginDialog::emitPluginSelected()
{
QListWidget* pluginList = ui->pluginList;
if (pluginList->currentItem() && pluginList->currentItem()->isSelected())
{
LXQt::PluginInfo plugin = mPlugins.at(pluginList->currentItem()->data(INDEX_ROLE).toInt());
emit pluginSelected(plugin);
}
}
示例2: 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);
}
示例3: DisplayProcess
void MainWindow::DisplayProcess()
{
QListWidget* list = this->ui.procListWidget;
QListWidgetItem* current = list->currentItem();
if (current == NULL)
return;
this->ui.procIdText->setText(current->text());
Process* process = this->model->getProcess(current->text().toInt());
if (process != NULL)
{
if(strlen(process->name) == 0x00)
{
this->window->setWindowTitle(QApplication::translate("window",
"Process Watch Dog", 0, QApplication::UnicodeUTF8));
}
else
{
this->window->setWindowTitle(QString("Application: [%1]").arg(process->name));
}
UpdateProcessStatusIcon(process);
}
}
示例4: getCurrentBuildingList
void LairTool::view3d(){
QListWidget* list = getCurrentBuildingList();
if (list == NULL)
return;
QListWidgetItem* item = list->currentItem();
if (item == NULL)
return;
QString file = item->text();
if (file.isEmpty())
return;
int idx = file.lastIndexOf("/");
if (idx < 0)
return;
file = file.insert(idx + 1, "shared_");
MainWindow::instance->startSwgOSG(file);
}
示例5: getItem
QString QtopiaInputDialog::getItem(QWidget *parent, const QString &title, const QString &label, const QStringList &list,
int current, bool *ok)
{
QListWidget *listWidget = new QListWidget;
listWidget->addItems(list);
listWidget->setCurrentRow(current);
listWidget->setFrameShadow(QFrame::Plain);
QtopiaInputDialog dlg(parent, title, label, listWidget);
bool accepted = (QtopiaApplication::execDialog(&dlg) == QDialog::Accepted);
if (ok)
*ok = accepted;
if (listWidget->currentItem())
return listWidget->currentItem()->text();
else
return QString();
}
示例6: createMap
void MainWindow::createMap(QString path, int bgWidth, int bgHeight, QString mapName, int mapStep, bool isImage) {
QListWidget *tokenList = ui->tokenPage->getUi()->m_tokenList;
TokenItem *currentTokenItem = dynamic_cast<TokenItem*>(tokenList->currentItem());
bool isMj = (m_User->getRole() == Role::ROLE_MJ);
Map *map = new Map(isImage, mapName, path, bgWidth, bgHeight, currentTokenItem, mapStep, isMj);
// Add Map to the database
RepositoryManager::s_MapRepository.insertMap(map);
// Initialize and open map
openMap(map, true);
}
示例7: onAssistantItemSelectionChanged
void MainWindow::onAssistantItemSelectionChanged()
{
QListWidget* widget = qobject_cast<QListWidget*>(m_assistantToolBox->currentWidget());
if (widget) {
QListWidgetItem* item = widget->currentItem();
if (item) {
QString notes = item->data(ASSISTANT_ITEM_NOTES_ROLE).toString();
m_assistantPreviewNotes->setText(notes.isEmpty() ?
tr("Code:") :
tr("Notes:<br>%1<br>Code:").arg(notes));
m_assistantCodePreview->setPlainText(item->data(ASSISTANT_ITEM_DATA_ROLE).toString());
}
}
}
示例8: insertItem
void ItemOrderList::insertItem(const QString &label, bool checked, bool highlight, const QIcon &icon,
const ItemPtr &item, int targetRow)
{
QListWidget *list = ui->listWidgetItems;
QListWidgetItem *listItem = new QListWidgetItem(icon, label);
const int row = targetRow >= 0 ? qMin(list->count(), targetRow) : list->count();
list->insertItem(row, listItem);
listItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
setItemHighlight(listItem, highlight);
m_items[listItem] = ItemWidgetPair(item);
// Resize list to minimal size.
const int w = list->sizeHintForColumn(0)
+ list->verticalScrollBar()->sizeHint().width() + 4;
list->setMaximumWidth(w);
if ( list->currentItem() == NULL )
list->setCurrentRow(row);
}
示例9: insertItem
void ItemOrderList::insertItem(const QString &label, bool checked, const QIcon &icon,
const ItemPtr &item, int targetRow)
{
QListWidget *list = ui->listWidgetItems;
auto listItem = new QListWidgetItem(icon, label);
listItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
m_items[listItem] = ItemWidgetPair(item, checked);
const int row = targetRow >= 0 ? qMin(list->count(), targetRow) : list->count();
list->insertItem(row, listItem);
// Resize list to minimal size.
if ( !isVisible() ) {
const int w = list->sizeHintForColumn(0)
+ list->verticalScrollBar()->sizeHint().width() + 4;
list->resize( w, list->height() );
}
if ( list->currentItem() == nullptr )
list->setCurrentRow(row);
}
示例10:
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_list_widget_current_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) {
QListWidgetItem *item = lw->currentItem ();
if (item) {
result = self->create_v8_qlistwidgetitem (item);
}
}
}
return scope.Close (result);
}
示例11: KDialog
AboutPlugins::AboutPlugins( Config *_config, QWidget* parent, Qt::WFlags f )
: KDialog( parent, f ),
config( _config ),
currentPlugin( 0 )
{
setCaption( i18n("About plugins") );
setWindowIcon( KIcon("preferences-plugin") );
setButtons( KDialog::Close );
setButtonFocus( KDialog::Close );
QWidget *widget = new QWidget( this );
setMainWidget( widget );
QHBoxLayout *box = new QHBoxLayout( widget );
QVBoxLayout *pluginListBox = new QVBoxLayout( widget );
box->addLayout( pluginListBox );
QLabel *installedPlugins = new QLabel( i18n("Installed plugins:"), this );
pluginListBox->addWidget( installedPlugins );
QListWidget *pluginsList = new QListWidget( this );
pluginListBox->addWidget( pluginsList );
connect( pluginsList, SIGNAL(currentTextChanged(const QString&)), this, SLOT(currentPluginChanged(const QString&)) );
QStringList pluginNames;
QList<CodecPlugin*> codecPlugins = config->pluginLoader()->getAllCodecPlugins();
for( int i=0; i<codecPlugins.count(); i++ )
{
pluginNames += codecPlugins.at(i)->name();
}
pluginNames.sort();
pluginsList->addItems( pluginNames );
pluginNames.clear();
QList<FilterPlugin*> filterPlugins = config->pluginLoader()->getAllFilterPlugins();
for( int i=0; i<filterPlugins.count(); i++ )
{
pluginNames += filterPlugins.at(i)->name();
}
pluginNames.sort();
pluginsList->addItems( pluginNames );
pluginNames.clear();
QList<ReplayGainPlugin*> replaygainPlugins = config->pluginLoader()->getAllReplayGainPlugins();
for( int i=0; i<replaygainPlugins.count(); i++ )
{
pluginNames += replaygainPlugins.at(i)->name();
}
pluginNames.sort();
pluginsList->addItems( pluginNames );
pluginNames.clear();
QList<RipperPlugin*> ripperPlugins = config->pluginLoader()->getAllRipperPlugins();
for( int i=0; i<ripperPlugins.count(); i++ )
{
pluginNames += ripperPlugins.at(i)->name();
}
pluginNames.sort();
pluginsList->addItems( pluginNames );
pluginsList->setFixedWidth( 180 );
box->addSpacing( 10 );
QVBoxLayout *pluginInfoBox = new QVBoxLayout( widget );
box->addLayout( pluginInfoBox );
aboutPluginLabel = new QLabel( this );
aboutPluginLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
aboutPluginLabel->setWordWrap( true );
aboutPluginLabel->setTextFormat( Qt::RichText );
pluginInfoBox->addWidget( aboutPluginLabel );
connect( aboutPluginLabel, SIGNAL(linkActivated(const QString&)), this, SLOT(showProblemInfo(const QString&)) );
pluginInfoBox->addStretch();
QHBoxLayout *configurePluginBox = new QHBoxLayout( widget );
pluginInfoBox->addLayout( configurePluginBox );
configurePlugin = new KPushButton( KIcon("configure"), "", widget );
configurePlugin->hide();
configurePluginBox->addWidget( configurePlugin );
configurePluginBox->addStretch();
connect( configurePlugin, SIGNAL(clicked()), this, SLOT(configurePluginClicked()) );
pluginsList->setCurrentRow(0);
QListWidgetItem *currentItem = pluginsList->currentItem();
if( currentItem )
{
currentPluginChanged( currentItem->text() );
}
setInitialSize( QSize(500,300) );
KSharedConfig::Ptr conf = KGlobal::config();
KConfigGroup group = conf->group( "AboutPlugins" );
restoreDialogSize( group );
}
示例12: actionExport_to_callback
void SvgCanvas::actionExport_to_callback()
{
QDialog dialog;
ExportToDialog export_to_dialog;
export_to_dialog.setupUi(&dialog);
QListWidget *list = export_to_dialog.formats_listWidget;
QListWidgetItem *item;
//Pixmaps formats
QList<QByteArray> formats=QImageWriter::supportedImageFormats();
for(int i=0;i<formats.size();i++)
{
QString text(formats[i]);
item=new QListWidgetItem(text,list);
item->setData(1,QVariant(PIXMAP));
}
//Vector formats
formats= QPicture::outputFormats();
for(int i=0;i<formats.size();i++)
{
QString text(formats[i]);
item=new QListWidgetItem(text,list);
item->setData(1,QVariant(PICTURE));
}
item=new QListWidgetItem("ps",list);
item->setData(1,QVariant(PRINTER));
item=new QListWidgetItem("pdf",list);
item->setData(1,QVariant(PDF));
item=new QListWidgetItem("svg",list);
item->setData(1,QVariant(SVG));
int ok=dialog.exec();
if(ok==QDialog::Rejected) return;
item =list->currentItem();
int format=item->data(1).toInt();
QPainter plot;
switch(format)
{
case PIXMAP:
{
bool ok;
int h, w = QInputDialog::getInteger(this, tr("Width"), tr("Width:"), 300, 0, 2147483647, 1, &ok);
if(!ok) return;
h=QInputDialog::getInteger(this, tr("Height"), tr("Height:"), 200, 0, 2147483647, 1, &ok);
if(!ok) return;
QString s = QFileDialog::getSaveFileName(this, "Choose a filename to save");
if(s.isEmpty()) return;
QImage image(w,h,QImage::Format_RGB32);
plot.begin(&image);
svg_plot->renderer()->render(&plot);
plot.end();
image.save(s,item->data(0).toString().toLocal8Bit().data());
}
break;
case PICTURE:
{
bool ok;
int h, w = QInputDialog::getInteger(this, tr("Width"), tr("Width:"), 300, 0, 2147483647, 1, &ok);
if(!ok) return;
h=QInputDialog::getInteger(this, tr("Height"), tr("Height:"), 200, 0, 2147483647, 1, &ok);
if(!ok) return;
QString s = QFileDialog::getSaveFileName(this, "Choose a filename to save");
if(s.isEmpty()) return;
QPicture image;
const QRect r(0,0,w,h);
image.setBoundingRect(r);
plot.begin(&image);
svg_plot->renderer()->render(&plot);
plot.end();
image.save(s,item->data(0).toString().toLocal8Bit().data());
}
break;
case PRINTER:
{
QPrinter p;
QPrintDialog printDialog(&p, this);
if (printDialog.exec() != QDialog::Accepted) return;
plot.begin(&p);
svg_plot->renderer()->render(&plot);
plot.end();
}
break;
case PDF:
{
QPrinter p;
QPrintDialog printDialog(&p, this);
p.setOutputFormat(QPrinter::PdfFormat);
if (printDialog.exec() != QDialog::Accepted) return;
plot.begin(&p);
svg_plot->renderer()->render(&plot);
plot.end();
}
break;
case SVG:
{
//.........这里部分代码省略.........