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


C++ QListWidget类代码示例

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


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

示例1: CustomContextMenu

void OBSBasicFilters::CustomContextMenu(const QPoint &pos, bool async)
{
	QListWidget *list = async ? ui->asyncFilters : ui->effectFilters;
	QListWidgetItem *item = list->itemAt(pos);

	QMenu popup(window());

	QPointer<QMenu> addMenu = CreateAddFilterPopupMenu(async);
	if (addMenu)
		popup.addMenu(addMenu);

	if (item) {
		const char *renameSlot = async ?
			SLOT(RenameAsyncFilter()) : SLOT(RenameEffectFilter());
		const char *removeSlot = async ?
			SLOT(on_removeAsyncFilter_clicked()) :
			SLOT(on_removeEffectFilter_clicked());

		popup.addSeparator();
		popup.addAction(QTStr("Rename"), this, renameSlot);
		popup.addAction(QTStr("Remove"), this, removeSlot);
	}

	popup.exec(QCursor::pos());
}
开发者ID:chaturbatecom,项目名称:obs-studio,代码行数:25,代码来源:window-basic-filters.cpp

示例2: obs_source_get_output_flags

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: while

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);
    }
开发者ID:4ukuta,项目名称:core,代码行数:27,代码来源:mainwindow.cpp

示例4: 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,"Недопустимая операция","Невозможно удалить последнюю строку");
    }
}
开发者ID:hermixy,项目名称:QtModbusLcd,代码行数:27,代码来源:mainwindow.cpp

示例5: foreach

void CReportDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    const QAbstractItemModel* model = index.model();
    QVariant data = index.data(Qt::DisplayRole);
    //Populate the editor
    if(data.type() != QVariant::List)
        QStyledItemDelegate::setEditorData(editor,index);

    QVariantList validReports = index.data(Qt::EditRole).toList();
    QVariantList currentReportsList = data.toList();

    QListWidget* listWidget = static_cast<QListWidget*>(editor);
    // Prepare the items in the list
    foreach(QVariant dataElement,validReports)
    {
        QString outString = dataElement.toString();
        if(m_reportNameModel!=(QAbstractItemModel*)NULL)
        {
            outString+=":"+searchReportColumnForId(dataElement.toInt());
        }
        QListWidgetItem* item = new QListWidgetItem(outString);
        item->setData(Qt::UserRole,dataElement);
        //Now, determine if the ítem SHOULD be checked
        if(currentReportsList.contains(dataElement))
        {
            item->setCheckState(Qt::Checked);

        }
        else
        {
            item->setCheckState(Qt::Unchecked);
        }

        listWidget->addItem(item);
    }
开发者ID:INSYEN,项目名称:DTNOTronAdminGUI,代码行数:35,代码来源:creportdelegate.cpp

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

示例7: resizeEvent

void MainWindow::resizeEvent(QResizeEvent *)
{
    QListWidget *lst = ui->lst_debug;
    QRect geo = lst->geometry();
    geo.setHeight( this->height() - geo.top() - 20 );
    lst->setGeometry(geo);
}
开发者ID:jlbfalcao,项目名称:hairless-midiserial,代码行数:7,代码来源:mainwindow.cpp

示例8: fatalMessageReceived

void MessageHandlerWidget::fatalMessageReceived(const QString &app, const QString &message,
                                                const QTime &time, const QStringList &backtrace)
{
  if (Endpoint::isConnected() && !qobject_cast<MessageHandlerClient*>(ObjectBroker::object<MessageHandlerInterface*>())) {
    // only show on remote side
    return;
  }
  QDialog dlg;
  dlg.setWindowTitle(QObject::tr("QFatal in %1 at %2").arg(app).arg(time.toString()));

  QGridLayout *layout = new QGridLayout;

  QLabel *iconLabel = new QLabel;
  QIcon icon = dlg.style()->standardIcon(QStyle::SP_MessageBoxCritical, 0, &dlg);
  int iconSize = dlg.style()->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, &dlg);
  iconLabel->setPixmap(icon.pixmap(iconSize, iconSize));
  iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
  layout->addWidget(iconLabel, 0, 0);

  QLabel *errorLabel = new QLabel;
  errorLabel->setTextFormat(Qt::PlainText);
  errorLabel->setWordWrap(true);
  errorLabel->setText(message);
  layout->addWidget(errorLabel, 0, 1);

  QDialogButtonBox *buttons = new QDialogButtonBox;

  if (!backtrace.isEmpty()) {
    QListWidget *backtraceWidget = new QListWidget;
    foreach (const QString &frame, backtrace) {
      backtraceWidget->addItem(frame);
    }
开发者ID:pangpangpang3,项目名称:GammaRay,代码行数:32,代码来源:messagehandlerwidget.cpp

示例9: strPaste

void MainWindow::strPaste(unsigned char strNum)
{
    QListWidget* list;
    list = nullptr;
    if(copyFlag==false)
    {
        QMessageBox::warning(this,"сообщение","Буфер обмена пуст");
        return;
    }
    else
    {
        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();
            lcd->getData()->insertLine(copyLine,strNum-1,i);
            lcd->setLineNumber(strNum-1,i);
            lcd->setPos(0,strNum-1);
            display->update();
            fillLists(lcd->getData());
        }
    }
}
开发者ID:hermixy,项目名称:QtModbusLcd,代码行数:29,代码来源:mainwindow.cpp

示例10: assert

void CQReportDefinition::btnItemClicked()
{
    assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
    CModel* pModel = (*CCopasiRootContainer::getDatamodelList())[0]->getModel();

    if (!pModel) return;

    std::vector< const CCopasiObject * > SelectedVector =
        //    CCopasiSelectionDialog::getObjectVector(this, CQSimpleSelectionTree::NO_RESTRICTION);
        CCopasiSelectionDialog::getObjectVector(this, CQSimpleSelectionTree::AnyObject);

    CQReportListItem * pItem;

    if (SelectedVector.size() != 0)
    {
        QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentPage());
        std::vector< const CCopasiObject * >::const_iterator it = SelectedVector.begin();
        std::vector< const CCopasiObject * >::const_iterator end = SelectedVector.end();

        for (; it != end; ++it)
        {
            pItem = new CQReportListItem(*it);
            pList->addItem(pItem);
        }

        mChanged = true;
    }

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

示例11: QWidget

//! [8]
ApplicationsTab::ApplicationsTab(const QFileInfo &fileInfo, QWidget *parent)
    : QWidget(parent)
{
    QLabel *topLabel = new QLabel(tr("Open with:"));

    QListWidget *applicationsListBox = new QListWidget;
    QStringList applications;

    for (int i = 1; i <= 30; ++i)
        applications.append(tr("Application %1").arg(i));
    applicationsListBox->insertItems(0, applications);

    QCheckBox *alwaysCheckBox;

    if (fileInfo.suffix().isEmpty())
        alwaysCheckBox = new QCheckBox(tr("Always use this application to "
            "open this type of file"));
    else
        alwaysCheckBox = new QCheckBox(tr("Always use this application to "
            "open files with the extension '%1'").arg(fileInfo.suffix()));

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(topLabel);
    layout->addWidget(applicationsListBox);
    layout->addWidget(alwaysCheckBox);
    setLayout(layout);
}
开发者ID:cometyang,项目名称:EagleEye,代码行数:28,代码来源:tabdialog.cpp

示例12: doEventPlace

void HistoryElementModifyEvent::doEventPlace()
{
    if(!m_scene)
        return;

    LvlScene* lvlScene;
    if(!(lvlScene = qobject_cast<LvlScene*>(m_scene)))
        return;

    LevelSMBX64Event rmEvents = m_event;

    MainWinConnect::pMainWin->dock_LvlEvents->setEventToolsLocked(true);
    QListWidgetItem * item;
    item = new QListWidgetItem;
    item->setText(rmEvents.name);
    item->setFlags(Qt::ItemIsEditable);
    item->setFlags(item->flags() | Qt::ItemIsEnabled);
    item->setFlags(item->flags() | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsSelectable);
    item->setData(Qt::UserRole, QString::number(rmEvents.meta.array_id) );
    QListWidget* evList = MainWinConnect::pMainWin->dock_LvlEvents->getEventList();
    LevelSMBX64Event NewEvent = rmEvents;


    lvlScene->m_data->events.push_back(NewEvent);
    evList->addItem(item);

    lvlScene->m_data->meta.modified = true;

    MainWinConnect::pMainWin->EventListsSync();
    MainWinConnect::pMainWin->dock_LvlEvents->setEventToolsLocked(false);
}
开发者ID:Wohlhabend-Networks,项目名称:PGE-Project,代码行数:31,代码来源:historyelementmodifyevent.cpp

示例13: QDialog

Dialog::Dialog( QWidget *parent ) : QDialog( parent )
{
	//ui.setupUi( this );
	QLabel *Label1 = new QLabel( tr( "Label1" ) );
	QLabel *Label2 = new QLabel( tr( "Label2" ) );
	QLabel *Label3 = new QLabel( tr( "Label3" ) );

	QListWidget *list = new QListWidget( this );
	list->insertItem( 0, tr( "Window1" ) );
	list->insertItem( 1, tr( "Window2" ) );
	list->insertItem( 2, tr( "Window3" ) );

	QStackedWidget *stack = new QStackedWidget( this );
	stack->addWidget( Label1 );
	stack->addWidget( Label2 );
	stack->addWidget( Label3 );

	QHBoxLayout *Layout = new QHBoxLayout( this );
	Layout->setMargin( 5 );
	Layout->setSpacing( 5 );
	Layout->addWidget( list );
	Layout->addWidget( stack, 0, Qt::AlignHCenter );
	Layout->setStretchFactor( list, 1 );
	Layout->setStretchFactor( stack, 3 );
	connect( list, SIGNAL( currentRowChanged( int ) ), stack, SLOT( setCurrentIndex( int ) ) );
}
开发者ID:zhangyaowu1993,项目名称:Zhang_Yao_Wu1993,代码行数:26,代码来源:QT.堆栈窗体.cpp

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

示例15: update

void ListBoxControl::update (int pId)
{
  uicontrol::properties& up = properties<uicontrol> ();
  QListWidget* list = qWidget<QListWidget> ();

  switch (pId)
    {
    case uicontrol::properties::ID_STRING:
      m_blockCallback = true;
      list->clear ();
      list->addItems (Utils::fromStringVector (up.get_string_vector ()));
      updateSelection (list, up.get_value ().matrix_value ());
      m_blockCallback = false;
      break;
    case uicontrol::properties::ID_MIN:
    case uicontrol::properties::ID_MAX:
      if ((up.get_max () - up.get_min ()) > 1)
	list->setSelectionMode (QAbstractItemView::ExtendedSelection);
      else
	list->setSelectionMode (QAbstractItemView::SingleSelection);
      break;
    case uicontrol::properties::ID_VALUE:
      m_blockCallback = true;
      updateSelection (list, up.get_value ().matrix_value ());
      m_blockCallback = false;
      break;
    default:
      BaseControl::update (pId);
      break;
    }
}
开发者ID:Htallon,项目名称:QtHandles,代码行数:31,代码来源:ListBoxControl.cpp


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