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


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

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


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

示例1: 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);
    }
}
开发者ID:hermixy,项目名称:QtModbusLcd,代码行数:28,代码来源:mainwindow.cpp

示例2: ProcessAdded

void MainWindow::ProcessAdded(Process* _process)
{
  QListWidget* list = this->ui.procListWidget;
  list->addItem(QString::number(_process->id, 10));

  QListWidgetItem* item = this->GetProcessItem(_process);
  if(item != NULL)
  {
    int row = list->row(item);
    list->setCurrentRow(row);
  }
}
开发者ID:dpsm,项目名称:pwatchdog,代码行数:12,代码来源:MainWindow.cpp

示例3: onPushButtonUpClicked

void ItemOrderList::onPushButtonUpClicked()
{
    QListWidget *list = ui->listWidgetItems;
    const int row = list->currentRow();
    if (row < 1)
        return;

    list->blockSignals(true);
    list->insertItem(row - 1, list->takeItem(row));
    list->setCurrentRow(row - 1);
    list->blockSignals(false);
}
开发者ID:amosbird,项目名称:CopyQ,代码行数:12,代码来源:itemorderlist.cpp

示例4: on_pushButtonDown_clicked

void ItemOrderList::on_pushButtonDown_clicked()
{
    QListWidget *list = ui->listWidgetItems;
    const int row = list->currentRow();
    if (row < 0 || row == list->count() - 1)
        return;

    list->blockSignals(true);
    list->insertItem(row + 1, list->takeItem(row));
    list->setCurrentRow(row + 1);
    list->blockSignals(false);
}
开发者ID:DINKIN,项目名称:CopyQ,代码行数:12,代码来源:itemorderlist.cpp

示例5: ProcessRemoved

void MainWindow::ProcessRemoved(Process* _process)
{
  QListWidgetItem* item = this->GetProcessItem(_process);
  QListWidget*     list = this->ui.procListWidget;
  if(item != NULL)
      delete list->takeItem(list->row(item));

  if (list->count() == 0x00)
    this->ResetUI();
  else
    list->setCurrentRow(0x00);
}
开发者ID:dpsm,项目名称:pwatchdog,代码行数:12,代码来源:MainWindow.cpp

示例6: updateSuggestions

void GuiSpellchecker::updateSuggestions(docstring_list & words)
{
	QString const suggestion = toqstr(d->word_.word());
	d->ui.wordED->setText(suggestion);
	QListWidget * lw = d->ui.suggestionsLW;
	lw->clear();

	if (words.empty()) {
		on_suggestionsLW_itemClicked(new QListWidgetItem(suggestion));
		return;
	}
	for (size_t i = 0; i != words.size(); ++i)
		lw->addItem(toqstr(words[i]));

	on_suggestionsLW_itemClicked(lw->item(0));
	lw->setCurrentRow(0);
}
开发者ID:bsjung,项目名称:Lyx,代码行数:17,代码来源:GuiSpellchecker.cpp

示例7: 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();
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:17,代码来源:qtopiainputdialog_p.cpp

示例8: selectItem

bool ThemeManager::selectItem(const QString& id, bool is_default)
{
	QListWidget* view = m_themes;
	QListWidget* other_view = m_default_themes;
	if (is_default) {
		std::swap(view, other_view);
	}
	QAbstractItemModel* model = view->model();
	QModelIndexList items = model->match(model->index(0, 0, QModelIndex()),
			Qt::UserRole, id, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive);
	if (!items.isEmpty()) {
		view->setCurrentRow(items.first().row());
		other_view->setCurrentIndex(other_view->rootIndex());
		m_tabs->setCurrentIndex(!is_default);
		return true;
	} else {
		return false;
	}
}
开发者ID:wkoomson,项目名称:focuswriter,代码行数:19,代码来源:theme_manager.cpp

示例9: 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);
}
开发者ID:DINKIN,项目名称:CopyQ,代码行数:20,代码来源:itemorderlist.cpp

示例10: 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);
}
开发者ID:amosbird,项目名称:CopyQ,代码行数:21,代码来源:itemorderlist.cpp

示例11: selectDialog

// **** keyboard selection dialog *********************************************
int KNHelper::selectDialog(QWidget *parent, const QString &caption, const QStringList &options, int initialValue)
{
  KDialog *dlg = new KDialog( parent );
  dlg->setCaption( caption );
  dlg->setButtons( KDialog::Ok|KDialog::Cancel );
  dlg->setDefaultButton( KDialog::Ok );

  QFrame *page = new QFrame( dlg );
  dlg->setMainWidget( page );
  QHBoxLayout *pageL = new QHBoxLayout(page);
  pageL->setSpacing(5);
  pageL->setMargin(8);

  QListWidget *list = new QListWidget( page );
  pageL->addWidget(list);

  QString s;
  for ( QStringList::ConstIterator it = options.begin(); it != options.end(); ++it ) {
    s = (*it);
    // remove accelerators
    s.replace( QRegExp( "&" ), "" ); // krazy:exclude=doublequote_chars
    list->addItem( s );
  }

  list->setCurrentRow( initialValue );
  list->setFocus();
  QObject::connect( list, SIGNAL( itemActivated( QListWidgetItem* ) ), dlg, SLOT( accept() ) );
  restoreWindowSize("selectBox", dlg, QSize(247,174));

  int ret;
  if (dlg->exec())
    ret = list->currentRow();
  else
    ret = -1;

  saveWindowSize("selectBox", dlg->size());
  delete dlg;
  return ret;
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:40,代码来源:utilities.cpp

示例12: 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 );
}
开发者ID:unwork-inc,项目名称:soundkonverter,代码行数:96,代码来源:aboutplugins.cpp

示例13: ui_companion_qt_init


//.........这里部分代码省略.........

   coreSelectionDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE), mainwindow);
   coreSelectionDock->setObjectName("coreSelectionDock");
   coreSelectionDock->setProperty("default_area", Qt::LeftDockWidgetArea);
   coreSelectionDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE));
   coreSelectionDock->setWidget(coreSelectionWidget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(coreSelectionDock->property("default_area").toInt()), coreSelectionDock);

   mainwindow->splitDockWidget(browserAndPlaylistTabDock, coreSelectionDock, Qt::Vertical);

#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
   mainwindow->resizeDocks(QList<QDockWidget*>() << coreSelectionDock, QList<int>() << 1, Qt::Vertical);
#endif

   /* this should come last */
   mainwindow->resizeThumbnails(true, true, true);

   if (qsettings->contains("all_playlists_list_max_count"))
      mainwindow->setAllPlaylistsListMaxCount(qsettings->value("all_playlists_list_max_count", 0).toInt());

   if (qsettings->contains("all_playlists_grid_max_count"))
      mainwindow->setAllPlaylistsGridMaxCount(qsettings->value("all_playlists_grid_max_count", 5000).toInt());

   if (qsettings->contains("geometry"))
      if (qsettings->contains("save_geometry"))
         mainwindow->restoreGeometry(qsettings->value("geometry").toByteArray());

   if (qsettings->contains("save_dock_positions"))
      if (qsettings->contains("dock_positions"))
         mainwindow->restoreState(qsettings->value("dock_positions").toByteArray());

   if (qsettings->contains("theme"))
   {
      QString themeStr = qsettings->value("theme").toString();
      MainWindow::Theme theme = mainwindow->getThemeFromString(themeStr);

      if (qsettings->contains("custom_theme") && theme == MainWindow::THEME_CUSTOM)
      {
         QString customThemeFilePath = qsettings->value("custom_theme").toString();

         mainwindow->setCustomThemeFile(customThemeFilePath);
      }

      mainwindow->setTheme(theme);
   }
   else
      mainwindow->setTheme();

   if (qsettings->contains("view_type"))
   {
      QString viewType = qsettings->value("view_type", "list").toString();

      if (viewType == "list")
         mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST);
      else if (viewType == "icons")
         mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_ICONS);
      else
         mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST);

      /* we set it to the same thing a second time so that m_lastViewType is also equal to the startup view type */
      mainwindow->setCurrentViewType(mainwindow->getCurrentViewType());
   }
   else
      mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST);

   /* We make sure to hook up the tab widget callback only after the tabs themselves have been added,
    * but before changing to a specific one, to avoid the callback firing before the view type is set.
    */
   QObject::connect(browserAndPlaylistTabWidget, SIGNAL(currentChanged(int)), mainwindow, SLOT(onTabWidgetIndexChanged(int)));

   /* setting the last tab must come after setting the view type */
   if (qsettings->contains("save_last_tab"))
   {
      int lastTabIndex = qsettings->value("last_tab", 0).toInt();

      if (lastTabIndex >= 0 && browserAndPlaylistTabWidget->count() > lastTabIndex)
      {
         browserAndPlaylistTabWidget->setCurrentIndex(lastTabIndex);
         mainwindow->onTabWidgetIndexChanged(lastTabIndex);
      }
   }
   else
   {
      browserAndPlaylistTabWidget->setCurrentIndex(0);
      mainwindow->onTabWidgetIndexChanged(0);
   }

   for (i = 0; i < listWidget->count() && listWidget->count() > 0; i++)
   {
      /* select the first non-hidden row */
      if (!listWidget->isRowHidden(i))
      {
         listWidget->setCurrentRow(i);
         break;
      }
   }

   return handle;
}
开发者ID:wiktorek140,项目名称:RetroArch,代码行数:101,代码来源:ui_qt.cpp

示例14: QGroupBox

lv2Description::lv2Description( QWidget * _parent,
						lv2PluginType _type ) :
	QWidget( _parent )
{
	lv2Manager * manager = static_lv2_manager;
/*
	switch( _type )
	{
		case SOURCE:
			plugins = manager->getInstruments();
			break;
		case TRANSFER:
			plugins = manager->getValidEffects();
			break;
		case VALID:
			plugins = manager->getValidEffects();
			break;
		case INVALID:
			plugins = manager->getInvalidEffects();
			break;
		case SINK:
			plugins = manager->getAnalysisTools();
			break;
		case OTHER:
			plugins = manager->getOthers();
			break;
		default:
			break;
	}
*/
 // Simpler : Get all the plugins, and select based on the type...
	l_sortable_plugin_t plugins = manager->getSortedPlugins();

	QList<QString> pluginNames;
	for( l_sortable_plugin_t::iterator it = plugins.begin();
		    it != plugins.end(); it++ )
	{
  lv2ManagerDescription * description=manager->getDescription( ( *it ).second );
		if( description->type == _type  &&
     (
      _type != VALID ||
      description->inputChannels <= engine::mixer()->audioOutputContext()->audioBackend()->channels()
     )
    )
		{
			pluginNames.push_back( ( *it ).first );
			m_pluginKeys.push_back( ( *it ).second );
		}
	}

	QGroupBox * pluginsBox = new QGroupBox( tr( "Plugins" ), this );
	QListWidget * pluginList = new QListWidget( pluginsBox );
	pluginList->addItems( pluginNames );
	connect( pluginList, SIGNAL( currentRowChanged( int ) ),
						SLOT( rowChanged( int ) ) );
	connect( pluginList, SIGNAL( itemDoubleClicked( QListWidgetItem * ) ),
				SLOT( onDoubleClicked( QListWidgetItem * ) ) );
	( new QVBoxLayout( pluginsBox ) )->addWidget( pluginList );

	QGroupBox * descriptionBox = new QGroupBox( tr( "Description" ), this );
	QVBoxLayout * descriptionLayout = new QVBoxLayout( descriptionBox );
	descriptionLayout->setSpacing( 0 );
	descriptionLayout->setMargin( 0 );

	m_scrollArea = new QScrollArea( descriptionBox );
	descriptionLayout->addWidget( m_scrollArea );

	QVBoxLayout * layout = new QVBoxLayout( this );
	layout->addWidget( pluginsBox );
	layout->addWidget( descriptionBox );

	if( pluginList->count() > 0 )
	{
		pluginList->setCurrentRow( 0 );
		m_currentSelection = m_pluginKeys[0];
		update( m_currentSelection );
	}
}
开发者ID:Orpheon,项目名称:lmms,代码行数:78,代码来源:lv2_description.cpp

示例15: fm

QWidget *ConfigDialog::centerWidget()
{
/*
	m_pagesTabWidget = new QTabWidget;
	for (int i = 0; i < m_pageWidgets.size(); ++i)
		m_pagesTabWidget->addTab(m_pageWidgets.at(i), m_pageTitles.at(i));
	return m_pagesTabWidget;
*/
	// create list
	QListWidget *pagesListWidget = new QListWidget;
	pagesListWidget->setViewMode(QListView::IconMode);
	pagesListWidget->setMovement(QListView::Static);
	pagesListWidget->setFlow(QListView::TopToBottom);
	pagesListWidget->setWordWrap(true);
	pagesListWidget->setUniformItemSizes(true);
	pagesListWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);

	// add items to list
	QFontMetrics fm(qApp->font());
	int iconWidth = 0;
	for (int i = 0; i < m_pagesListWidgetItems.size(); ++i)
		iconWidth = qMax(iconWidth, fm.boundingRect(0, 0, 0, 0, Qt::AlignCenter, m_pagesListWidgetItems.at(i)->text()).width());
	iconWidth += 20;
	const int iconHeight = fm.height() + 42;
	for (int i = 0; i < m_pagesListWidgetItems.size(); ++i)
	{
		m_pagesListWidgetItems.at(i)->setSizeHint(QSize(iconWidth, iconHeight));
		pagesListWidget->addItem(m_pagesListWidgetItems.at(i));
	}
	pagesListWidget->setFixedWidth(m_pagesListWidgetItems.at(0)->sizeHint().width() + 6);

	// create title
	QFrame *titleFrame = new QFrame(this);
//	titleFrame->setAutoFillBackground(true);
//	titleFrame->setFrameShape(QFrame::StyledPanel);
	titleFrame->setFrameShape(QFrame::Box);
//	titleFrame->setFrameShadow(QFrame::Plain);
//	titleFrame->setBackgroundRole(QPalette::Base);
	m_pagesTitleLabel = new QLabel(titleFrame);
	m_pagesTitleLabel->setStyleSheet("QLabel { font-weight: bold; }");
	QGridLayout *titleLayout = new QGridLayout(titleFrame);
	titleLayout->setColumnStretch(0, 1);
	titleLayout->setMargin(6);
	titleLayout->addWidget(m_pagesTitleLabel);

	// add pages
	QStackedWidget *pagesStackedWidget = new QStackedWidget;
	for (int i = 0; i < m_pageWidgets.size(); ++i)
		pagesStackedWidget->addWidget(m_pageWidgets.at(i));
	connect(pagesListWidget, SIGNAL(currentRowChanged(int)), pagesStackedWidget, SLOT(setCurrentIndex(int)));
	connect(pagesListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setCurrentPage(int)));
	pagesListWidget->setCurrentRow(0);

	QWidget *mainWidget = new QWidget;
	QGridLayout *mainLayout = new QGridLayout;
	mainLayout->addWidget(pagesListWidget, 0, 0, 2, 1);
	mainLayout->addWidget(titleFrame, 0, 1);
	mainLayout->addWidget(pagesStackedWidget, 1, 1);
	mainWidget->setLayout(mainLayout);

	return mainWidget;
}
开发者ID:jfmcarreira,项目名称:ktikz-old,代码行数:62,代码来源:configdialog.cpp


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