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


C++ QComboBox::setMaxVisibleItems方法代码示例

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


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

示例1: addTriplet

void ContactDialog::addTriplet(int& count, QGridLayout* l, const QString& nameTemplate, const QString& itemValue)
{
    if (count>=MIN_VISIBLE_TRIPLETS) {
        // Value
        QLineEdit* le = new QLineEdit(this);
        le->setObjectName(QString("le%1%2").arg(nameTemplate).arg(count+1));
        l->addWidget(le, count, 0);
        // Item type combo box
        QComboBox* cbT = new QComboBox(this);
        cbT->setObjectName(QString("cb%1Type%2").arg(nameTemplate).arg(count+1));
        cbT->setMaxVisibleItems(32); // "mixed" (last item) must be strongly visible
        connect(cbT, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(itemTypeChanged(const QString&)));
        l->addWidget(cbT, count, 1);
        // Delete button
        QToolButton* btnD = addDelButton(count, nameTemplate, SLOT(slotDelTriplet()));
        l->addWidget(btnD, count, 2);
    }
开发者ID:DarkHobbit,项目名称:doublecontact,代码行数:17,代码来源:contactdialog.cpp

示例2: updateTable


//.........这里部分代码省略.........
    for (i=0; i<ASCII_OPEN_DLG_TYPES_NUMBER; i++)
        propsText << QString(ASCII_OPEN_DLG_TYPES_NAMES[i]);

    //remove unnecessary columns
    while (columnsCount<m_columnsCount)
        tableWidget->removeColumn(--m_columnsCount);
    for (i=lineCount+1; i<=DISPLAYED_LINES; ++i)
        tableWidget->removeRow(i);

    int columnWidth = (tableWidget->width()*9) / (columnsCount*10);
    columnWidth = ccMax(columnWidth,80);

    //Icons
    const QIcon xIcon(QString::fromUtf8(":/CC/Types/images/types/x_coordinate.png"));
    const QIcon yIcon(QString::fromUtf8(":/CC/Types/images/types/y_coordinate.png"));
    const QIcon zIcon(QString::fromUtf8(":/CC/Types/images/types/z_coordinate.png"));
    const QIcon NormIcon(QString::fromUtf8(":/CC/Types/images/types/normal.png"));
    const QIcon RGBIcon(QString::fromUtf8(":/CC/Types/images/types/rgb_color.png"));
    const QIcon GreyIcon(QString::fromUtf8(":/CC/Types/images/types/gray_color.png"));
    const QIcon ScalarIcon(QString::fromUtf8(":/CC/Types/images/types/scalar_field.png"));
    const QIcon PositiveScalarIcon(QString::fromUtf8(":/CC/Types/images/types/positive_scalar_field.png"));

    unsigned assignedXYZ = 0;
    unsigned assignedNorm = 0;
    unsigned assignedRGB = 0;
    for (i=0; i<columnsCount; i++)
    {
        QComboBox* columnHeader = static_cast<QComboBox*>(tableWidget->cellWidget(0,i));
        QComboBox* _columnHeader = columnHeader;
        if (!columnHeader)
        {
            columnHeader = new QComboBox();
            columnHeader->addItems(propsText);
            columnHeader->setMaxVisibleItems(ASCII_OPEN_DLG_TYPES_NUMBER);
            columnHeader->setCurrentIndex(0);
            columnHeader->setItemIcon(ASCII_OPEN_DLG_X,xIcon);
            columnHeader->setItemIcon(ASCII_OPEN_DLG_Y,yIcon);
            columnHeader->setItemIcon(ASCII_OPEN_DLG_Z,zIcon);
            columnHeader->setItemIcon(ASCII_OPEN_DLG_NX,NormIcon);
            columnHeader->setItemIcon(ASCII_OPEN_DLG_NY,NormIcon);
            columnHeader->setItemIcon(ASCII_OPEN_DLG_NZ,NormIcon);
            columnHeader->setItemIcon(ASCII_OPEN_DLG_R,RGBIcon);
            columnHeader->setItemIcon(ASCII_OPEN_DLG_G,RGBIcon);
            columnHeader->setItemIcon(ASCII_OPEN_DLG_B,RGBIcon);
            columnHeader->setItemIcon(ASCII_OPEN_DLG_Grey,GreyIcon);
            columnHeader->setItemIcon(ASCII_OPEN_DLG_Scalar,ScalarIcon);
            columnHeader->setItemIcon(ASCII_OPEN_DLG_Positive_Scalar,PositiveScalarIcon);

            connect(columnHeader, SIGNAL(currentIndexChanged(int)), this, SLOT(columnsTypeHasChanged(int)));
        }

        if (valueIsNumber[i])
        {
            //first time? let's try to assign each column a type
            if ((m_invalidColumns || m_columnsCount==0) && columnsCount>1)
            {
                columnHeader->blockSignals(true);
                //by default, we assume that the first columns are always X,Y and Z
                if (assignedXYZ<3)
                {
                    //in rare cases, the first column is an index
                    if (assignedXYZ==0 && valueIsInteger[i] && (i+1<columnsCount) && !valueIsInteger[i+1])
                    {
                        //we skip it
                    }
                    else
开发者ID:whatnick,项目名称:CloudCompare,代码行数:67,代码来源:AsciiOpenDlg.cpp

示例3: if

QWidget *AnemDelegate::createEditor(QWidget* parent,
                                     const QStyleOptionViewItem& option,
                                     const QModelIndex& index) const
{
    Q_UNUSED(option)

    QLabel *label;
    QComboBox *combo;
    QDoubleSpinBox *dspin;
    QLineEdit *ledit;
    QString currentManufacturer = index.model()->data(index.model()->index(AnemModel::MANUFACTURER, index.column())).toString();
    QString currentModel = index.model()->data(index.model()->index(AnemModel::MODEL, index.column())).toString();

    // can only edit name on blank column
    if (index.column() >= index.model()->columnCount()) return 0;

    // different kind of editor for each row
    switch (index.row())
    {
      case AnemModel::MANUFACTURER:
          combo = new QComboBox(parent);
          combo->setEditable(false);
          combo->addItems(AnemDesc::manufacturerStringList());
          combo->view()->setTextElideMode(Qt::ElideNone);
          connect(combo, SIGNAL(activated(int)),
                  this, SLOT(commitAndCloseEditor()));
          return combo;
      case AnemModel::MODEL:
          combo = new QComboBox(parent);
          combo->setEditable(false);
          if (currentManufacturer.isEmpty())
          {
              combo->addItems(AnemDesc::allModelStringList());
          }
          else if (currentManufacturer == AnemDesc::getANEM_MANUFACTURER_STRING_0())
          {
              combo->addItems(AnemDesc::campbellModelStringList());
          }
          else if (currentManufacturer == AnemDesc::getANEM_MANUFACTURER_STRING_1())
          {
              combo->addItems(AnemDesc::gillModelStringList());
          }
          else if (currentManufacturer == AnemDesc::getANEM_MANUFACTURER_STRING_2())
          {
              combo->addItems(AnemDesc::metekModelStringList());
          }
          else if (currentManufacturer == AnemDesc::getANEM_MANUFACTURER_STRING_3())
          {
              combo->addItems(AnemDesc::youngModelStringList());
          }
          else if (currentManufacturer == AnemDesc::getANEM_MANUFACTURER_STRING_4())
          {
              combo->addItems(AnemDesc::otherModelStringList());
          }
          combo->view()->setTextElideMode(Qt::ElideNone);
          combo->setMaxVisibleItems(15);
          connect(combo, SIGNAL(activated(int)),
                  this, SLOT(commitAndCloseEditor()));
          return combo;
      case AnemModel::ID:
          ledit = new QLineEdit(parent);
          connect(ledit, SIGNAL(editingFinished()),
                  this, SLOT(commitAndCloseEditor()));
          return ledit;
      case AnemModel::HEIGHT:
          dspin = new QDoubleSpinBox(parent);
          dspin->setDecimals(2);
          dspin->setRange(0.1, 500.0);
          dspin->setSingleStep(1.0);
          dspin->setAccelerated(true);
          dspin->setSuffix(QStringLiteral(" [m]"));
          connect(dspin, SIGNAL(editingFinished()),
                  this, SLOT(commitAndCloseEditor()));
          return dspin;
      case AnemModel::WINDFORMAT:
          combo = new QComboBox(parent);
          combo->setEditable(false);
          if (currentManufacturer.isEmpty()
              || currentManufacturer == AnemDesc::getANEM_MANUFACTURER_STRING_1())
          {
              combo->addItems(AnemDesc::allWindFormatStringList());
          }
          else if (currentManufacturer == AnemDesc::getANEM_MANUFACTURER_STRING_0())
          {
              combo->addItems(AnemDesc::simplestWindFormatStringList());
          }
          else
          {
              combo->addItems(AnemDesc::commonWindFormatStringList());
          }
          combo->view()->setTextElideMode(Qt::ElideNone);
          connect(combo, SIGNAL(activated(int)),
                  this, SLOT(commitAndCloseEditor()));
          return combo;
      case AnemModel::NORTHALIGNMENT:
          combo = new QComboBox(parent);
          combo->setEditable(false);
          if (currentManufacturer.isEmpty())
          {
              combo->addItems(AnemDesc::allNorthAlignmentStringList());
//.........这里部分代码省略.........
开发者ID:jiaoy06,项目名称:eddypro-gui,代码行数:101,代码来源:anem_delegate.cpp

示例4: drv_combobox

int drv_combobox(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9)
{
    handle_head* head = (handle_head*)a0;
    QComboBox *self = (QComboBox*)head->native;
    switch (drvid) {
    case COMBOBOX_INIT: {
        drvNewObj(a0,new QComboBox);
        break;
    }
    case COMBOBOX_COUNT: {
        drvSetInt(a1,self->count());
        break;
    }
    case COMBOBOX_SETCURRENTINDEX: {
        self->setCurrentIndex(drvGetInt(a1));
        break;
    }
    case COMBOBOX_CURRENTINDEX: {
        drvSetInt(a1,self->currentIndex());
        break;
    }
    case COMBOBOX_CURRENTTEXT: {
        drvSetString(a1,self->currentText());
        break;
    }
    case COMBOBOX_SETEDITABLE: {
        self->setEditable(drvGetBool(a1));
        break;
    }
    case COMBOBOX_ISEDITABLE: {
        drvSetBool(a1,self->isEditable());
        break;
    }
    case COMBOBOX_SETMAXCOUNT: {
        self->setMaxCount(drvGetInt(a1));
        break;
    }
    case COMBOBOX_MAXCOUNT: {
        drvSetInt(a1,self->maxCount());
        break;
    }
    case COMBOBOX_SETMAXVISIBLEITEMS: {
        self->setMaxVisibleItems(drvGetInt(a1));
        break;
    }
    case COMBOBOX_MAXVISIBLEITEMS: {
        drvSetInt(a1,self->maxVisibleItems());
        break;
    }
    case COMBOBOX_SETMINIMUMCONTENTSLENGTH: {
        self->setMinimumContentsLength(drvGetInt(a1));
        break;
    }
    case COMBOBOX_MINIMUNCONTENTSLENGHT: {
        drvSetInt(a1,self->minimumContentsLength());
        break;
    }
    case COMBOBOX_ADDITEM: {
        self->addItem(drvGetString(a1));
        break;
    }
    case COMBOBOX_INSERTITEM: {
        self->insertItem(drvGetInt(a1),drvGetString(a2));
        break;
    }
    case COMBOBOX_REMOVEITEM: {
        self->removeItem(drvGetInt(a1));
        break;
    }
    case COMBOBOX_ITEMTEXT: {
        drvSetString(a2,self->itemText(drvGetInt(a1)));
        break;
    }
    case COMBOBOX_ONCURRENTINDEXCHANGED: {
        QObject::connect(self,SIGNAL(currentIndexChanged(int)),drvNewSignal(self,a1,a2),SLOT(call(int)));
        break;
    }
    default:
        return 0;
    }
    return 1;
}
开发者ID:weigj,项目名称:loongide,代码行数:82,代码来源:cdrv.cpp

示例5: updateTable


//.........这里部分代码省略.........
	//average line size
	m_averageLineSize = static_cast<double>(totalChars) / lineCount;
	unsigned approximateTotalLineCount = static_cast<unsigned>(file.size() / m_averageLineSize);

	//we add a type selector for each column
	QStringList propsText;
	{
		propsText.reserve(ASCII_OPEN_DLG_TYPES_COUNT);
		for (unsigned i = 0; i < ASCII_OPEN_DLG_TYPES_COUNT; i++)
		{
			propsText << QString(ASCII_OPEN_DLG_TYPES_NAMES[i]);
		}
	}

	//remove unnecessary columns
	{
		while (columnsCount < m_columnsCount)
			m_ui->tableWidget->removeColumn(--m_columnsCount);
		if (m_columnType.size() > columnsCount)
			m_columnType.resize(columnsCount, UNKNOWN);
		for (unsigned i = lineCount + 1; i <= DISPLAYED_LINES; ++i)
			m_ui->tableWidget->removeRow(i);
	}

	//setup table and widgets
	{
		//Icons
		static const QIcon xIcon		(QString::fromUtf8(":/CC/images/typeXCoordinate.png"));
		static const QIcon yIcon		(QString::fromUtf8(":/CC/images/typeYCoordinate.png"));
		static const QIcon zIcon		(QString::fromUtf8(":/CC/images/typeZCoordinate.png"));
		static const QIcon NormIcon		(QString::fromUtf8(":/CC/images/typeNormal.png"));
		static const QIcon RGBIcon		(QString::fromUtf8(":/CC/images/typeRgbCcolor.png"));
		static const QIcon GreyIcon		(QString::fromUtf8(":/CC/images/typeGrayColor.png"));
		static const QIcon ScalarIcon	(QString::fromUtf8(":/CC/images/typeSF.png"));
		static const QIcon LabelIcon	(QString::fromUtf8(":/CC/images/dbLabelSymbol.png"));

		int columnWidth = (m_ui->tableWidget->width() * 9) / (columnsCount * 10);
		columnWidth = std::max(columnWidth, 80);

		for (unsigned i = 0; i < columnsCount; i++)
		{
			QComboBox* columnHeaderWidget = static_cast<QComboBox*>(m_ui->tableWidget->cellWidget(0, i));
			QComboBox* _columnHeader = columnHeaderWidget;
			if (!columnHeaderWidget)
			{
				columnHeaderWidget = new QComboBox();
				columnHeaderWidget->addItems(propsText);
				columnHeaderWidget->setMaxVisibleItems(ASCII_OPEN_DLG_TYPES_COUNT);
				columnHeaderWidget->setCurrentIndex(0);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_X, xIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Y, yIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Z, zIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_NX, NormIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_NY, NormIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_NZ, NormIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_R, RGBIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_G, RGBIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_B, RGBIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Rf, RGBIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Gf, RGBIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Bf, RGBIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Grey, GreyIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_RGB32i, RGBIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_RGB32f, RGBIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Label, LabelIcon);
				columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Scalar, ScalarIcon);

				connect(columnHeaderWidget, SIGNAL(currentIndexChanged(int)), this, SLOT(columnsTypeHasChanged(int)));
			}

			while (m_columnType.size() <= static_cast<size_t>(i))
				m_columnType.push_back(UNKNOWN);
			assert(m_columnType.size() >= static_cast<size_t>(i));

			if (!_columnHeader)
				m_ui->tableWidget->setCellWidget(0, i, columnHeaderWidget);
			m_ui->tableWidget->setColumnWidth(i, columnWidth);

			//a non-numerical column can't be valid
			if (!valueIsNumber[i])
				m_columnType[i] = TEXT;
			else
				// we must do this to ensure we can get a correct result.
				// Otherwise, we may fail in such situations:
				//
				// FILE:
				// Line1   : $ gps file
				// Line2   : $ id name x y z
				// Line3   : 500
				// Line4   : 0    0001.JPG  753811.417453   4307200.381522      1957.803955
				// Linex   : ......
				// Line503 : 499  0500.JPG  753630.672714   4307195.433217      1957.803955
				// 
				// Description:
				// once we open the file, we will get a %m_columnType with 5 values of "TEXT"
				// then if we choose to skip the 3 first lines, we get a %valueIsNumber with 5 "true"
				// but the %m_columnType is still with 5 values of "TEXT" which leads to the failure!
				m_columnType[i] = UNKNOWN;
		}
	}
开发者ID:Puwong,项目名称:CloudCompare,代码行数:101,代码来源:AsciiOpenDlg.cpp

示例6: updateTable


//.........这里部分代码省略.........
            ++n;
        if (n != 0)
            m_headerLine.remove(0,n);
        m_ui->headerLabel->setText(QString("Header: ")+m_headerLine);
        m_ui->headerLabel->setVisible(true);
    }
    else
    {
        m_ui->headerLabel->setVisible(false);
    }

    m_ui->commentLinesSkippedLabel->setVisible(commentLines != 0);
    if (commentLines)
        m_ui->commentLinesSkippedLabel->setText(QString("+ %1 comment line(s) skipped").arg(commentLines));

    if (lineCount == 0 || columnsCount == 0)
    {
        m_averageLineSize = -1.0;
        m_ui->tableWidget->clear();
        m_columnsValidty.clear();
        return;
    }

    //average line size
    m_averageLineSize = static_cast<double>(totalChars)/lineCount;

    //we add a type selector for each column
    QStringList propsText;
    {
        for (unsigned i=0; i<ASCII_OPEN_DLG_TYPES_NUMBER; i++)
            propsText << QString(ASCII_OPEN_DLG_TYPES_NAMES[i]);
    }

    //remove unnecessary columns
    {
        while (columnsCount < m_columnsCount)
            m_ui->tableWidget->removeColumn(--m_columnsCount);
        if (m_columnsValidty.size() > columnsCount)
            m_columnsValidty.resize(columnsCount);
        for (unsigned i=lineCount+1; i<=DISPLAYED_LINES; ++i)
            m_ui->tableWidget->removeRow(i);
    }

    //setup table and widgets
    {
        //Icons
        static const QIcon xIcon		(QString::fromUtf8(":/CC/images/typeXCoordinate.png"));
        static const QIcon yIcon		(QString::fromUtf8(":/CC/images/typeYCoordinate.png"));
        static const QIcon zIcon		(QString::fromUtf8(":/CC/images/typeZCoordinate.png"));
        static const QIcon NormIcon		(QString::fromUtf8(":/CC/images/typeNormal.png"));
        static const QIcon RGBIcon		(QString::fromUtf8(":/CC/images/typeRgbCcolor.png"));
        static const QIcon GreyIcon		(QString::fromUtf8(":/CC/images/typeGrayColor.png"));
        static const QIcon ScalarIcon	(QString::fromUtf8(":/CC/images/typeSF.png"));

        int columnWidth = (m_ui->tableWidget->width()*9) / (columnsCount*10);
        columnWidth = std::max(columnWidth,80);

        for (unsigned i=0; i<columnsCount; i++)
        {
            QComboBox* columnHeaderWidget = static_cast<QComboBox*>(m_ui->tableWidget->cellWidget(0,i));
            QComboBox* _columnHeader = columnHeaderWidget;
            if (!columnHeaderWidget)
            {
                columnHeaderWidget = new QComboBox();
                columnHeaderWidget->addItems(propsText);
                columnHeaderWidget->setMaxVisibleItems(ASCII_OPEN_DLG_TYPES_NUMBER);
                columnHeaderWidget->setCurrentIndex(0);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_X,xIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Y,yIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Z,zIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_NX,NormIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_NY,NormIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_NZ,NormIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_R,RGBIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_G,RGBIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_B,RGBIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Rf,RGBIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Gf,RGBIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Bf,RGBIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Grey,GreyIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_Scalar,ScalarIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_RGB32i,RGBIcon);
                columnHeaderWidget->setItemIcon(ASCII_OPEN_DLG_RGB32f,RGBIcon);

                connect(columnHeaderWidget, SIGNAL(currentIndexChanged(int)), this, SLOT(columnsTypeHasChanged(int)));
            }

            while (m_columnsValidty.size() <= static_cast<size_t>(i))
                m_columnsValidty.push_back(false);
            assert(m_columnsValidty.size() >= static_cast<size_t>(i));

            if (!_columnHeader)
                m_ui->tableWidget->setCellWidget(0,i,columnHeaderWidget);
            m_ui->tableWidget->setColumnWidth(i,columnWidth);

            //a non-numerical column can't be valid
            if (!valueIsNumber[i])
                m_columnsValidty[i] = false;
        }
    }
开发者ID:vellano,项目名称:CloudCompare,代码行数:101,代码来源:AsciiOpenDlg.cpp

示例7: KDialog

static mpdm_t kde4_drv_form(mpdm_t a, mpdm_t ctxt)
{
    int n;
    mpdm_t widget_list;
    QWidget *qlist[100];
    mpdm_t r;

    KDialog *dialog = new KDialog(window);

    dialog->setModal(true);
    dialog->setButtons(KDialog::Ok | KDialog::Cancel);

    widget_list = mpdm_aget(a, 0);

    KVBox *vb = new KVBox(dialog);
    dialog->setMainWidget(vb);

    for (n = 0; n < mpdm_size(widget_list); n++) {
        mpdm_t w = mpdm_aget(widget_list, n);
        wchar_t *type;
        mpdm_t t;
        KHBox *hb = new KHBox(vb);

        type = mpdm_string(mpdm_hget_s(w, L"type"));

        if ((t = mpdm_hget_s(w, L"label")) != NULL) {
            QLabel *ql = new QLabel(hb);
            ql->setText(str_to_qstring(mpdm_gettext(t)));
        }

        t = mpdm_hget_s(w, L"value");

        if (wcscmp(type, L"text") == 0) {
            mpdm_t h;
            QComboBox *ql = new QComboBox(hb);

            ql->setEditable(true);
            ql->setMinimumContentsLength(30);
            ql->setMaxVisibleItems(8);

            if (t != NULL)
                ql->setEditText(str_to_qstring(t));

            qlist[n] = ql;

            if ((h = mpdm_hget_s(w, L"history")) != NULL) {
                int i;

                /* has history; fill it */
                h = mp_get_history(h);

                for (i = mpdm_size(h) - 1; i >= 0; i--)
                    ql->addItem(str_to_qstring(mpdm_aget(h, i)));
            }
        }
        else
        if (wcscmp(type, L"password") == 0) {
            QLineEdit *ql = new QLineEdit(hb);

            ql->setEchoMode(QLineEdit::Password);

            qlist[n] = ql;
        }
        else
        if (wcscmp(type, L"checkbox") == 0) {
            QCheckBox *qc = new QCheckBox(hb);

            if (mpdm_ival(t))
                qc->setCheckState(Qt::Checked);

            qlist[n] = qc;
        }
        else
        if (wcscmp(type, L"list") == 0) {
            int i;
            QListWidget *ql = new QListWidget(hb);
            ql->setMinimumWidth(480);

            /* use a monospaced font */
            ql->setFont(QFont(QString("Mono")));

            mpdm_t l = mpdm_hget_s(w, L"list");

            for (i = 0; i < mpdm_size(l); i++)
                ql->addItem(str_to_qstring(mpdm_aget(l, i)));

            ql->setCurrentRow(mpdm_ival(t));

            qlist[n] = ql;
        }

        if (n == 0)
            qlist[n]->setFocus(Qt::OtherFocusReason);
    }

    n = dialog->exec();

    if (!n)
        return NULL;

//.........这里部分代码省略.........
开发者ID:rofl0r,项目名称:mp-5.x,代码行数:101,代码来源:mpv_kde4.cpp

示例8: if

QWidget *IrgaDelegate::createEditor(QWidget* parent,
                                     const QStyleOptionViewItem& option,
                                     const QModelIndex& index) const
{
    DEBUG_FUNC_NAME
    Q_UNUSED(option)

    QLabel *label;
    QComboBox *combo;
    QDoubleSpinBox *dspin;
    QLineEdit *ledit;
    QString currentManufacturer = index.model()->data(index.model()->index(IrgaModel::MANUFACTURER, index.column())).toString();
    QString currentModel = index.model()->data(index.model()->index(IrgaModel::MODEL, index.column())).toString();

//    qDebug() << "index.row()" << index.row();

    // can only edit name on blank column
    if (index.column() >= index.model()->columnCount()) return 0;

    // different kind of editor for each row
    switch (index.row())
    {
      case IrgaModel::MANUFACTURER:
          combo = new QComboBox(parent);
          combo->setEditable(false);
          combo->addItems(IrgaDesc::manufacturerStringList());
          combo->view()->setTextElideMode(Qt::ElideNone);
          connect(combo, SIGNAL(activated(int)),
                  this, SLOT(commitAndCloseEditor()));
          return combo;
      case IrgaModel::MODEL:
          combo = new QComboBox(parent);
          combo->setEditable(false);
          if (currentManufacturer.isEmpty())
          {
              combo->addItems(IrgaDesc::allModelStringList());
          }
          else if (currentManufacturer == IrgaDesc::getIRGA_MANUFACTURER_STRING_0())
          {
              combo->addItems(IrgaDesc::licorModelStringList());
          }
          else if (currentManufacturer == IrgaDesc::getIRGA_MANUFACTURER_STRING_1())
          {
              combo->addItems(IrgaDesc::otherModelStringList());
          }
          combo->view()->setTextElideMode(Qt::ElideNone);
          combo->setMaxVisibleItems(15);
          connect(combo, SIGNAL(activated(int)),
                  this, SLOT(commitAndCloseEditor()));
          return combo;
      case IrgaModel::SWVERSION:
            ledit = new QLineEdit(parent);
            ledit->setPlaceholderText(QStringLiteral("8.0.0"));
            connect(ledit, SIGNAL(editingFinished()),
                    this, SLOT(commitAndCloseEditor()));
            return ledit;
      case IrgaModel::ID:
            ledit = new QLineEdit(parent);
            ledit->setPlaceholderText(QStringLiteral("Alphanumeric ID"));
            connect(ledit, SIGNAL(editingFinished()),
                  this, SLOT(commitAndCloseEditor()));
            return ledit;
      case IrgaModel::TUBELENGTH:
            if (IrgaDesc::isOpenPathModel(currentModel))
            {
                label = new QLabel(parent);
                return label;
            }
            else
            {
                dspin = new QDoubleSpinBox(parent);
                dspin->setDecimals(1);
                dspin->setRange(0.0, 9999.0);
                dspin->setSingleStep(1.0);
                dspin->setAccelerated(true);
                dspin->setSuffix(QStringLiteral(" [cm]"));
                connect(dspin, SIGNAL(editingFinished()),
                      this, SLOT(commitAndCloseEditor()));
                return dspin;
            }
      case IrgaModel::TUBEDIAMETER:
            if (IrgaDesc::isOpenPathModel(currentModel))
            {
                label = new QLabel(parent);
                return label;
            }
            else
            {
              dspin = new QDoubleSpinBox(parent);
              dspin->setDecimals(1);
              dspin->setRange(0.0, 99.0);
              dspin->setSingleStep(1.0);
              dspin->setAccelerated(true);
              dspin->setSuffix(QStringLiteral(" [mm]"));
              connect(dspin, SIGNAL(editingFinished()),
                      this, SLOT(commitAndCloseEditor()));
              return dspin;
            }
      case IrgaModel::TUBEFLOWRATE:
            if (IrgaDesc::isOpenPathModel(currentModel))
//.........这里部分代码省略.........
开发者ID:LI-COR,项目名称:eddypro-gui,代码行数:101,代码来源:irga_delegate.cpp


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