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


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

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


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

示例1: setWindowTitle

MainWindow::MainWindow(QWidget *parent, QFlag flags) :
	QMainWindow(parent, flags)
{
    // Set window title
    setWindowTitle("3D Computergrafik I - SS2015 - Aufgabenblatt 4");

    // Create main container
    QWidget *container = new QWidget();
    setCentralWidget(container);

    // Add list (on the left)
    QListWidget *list = new QListWidget(container);
    list->addItem("Aufgabe 12");
    list->addItem("Aufgabe 13");
    list->addItem("Aufgabe 14");
    list->setMaximumWidth(150);

    // Add stack of exercise windows (on the right)
    QStackedWidget *stack = new QStackedWidget(container);

    // Add exercises to widget
    stack->addWidget(new GLViewer(new Exercise12()));
    stack->addWidget(new GLViewer(new Exercise13()));
    stack->addWidget(new GLViewer(new Exercise14()));

    // Create layout
    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(list);
    layout->addWidget(stack);
    container->setLayout(layout);

    // Connect selection-event of list to select the current visible window
    connect(list, SIGNAL(currentRowChanged(int)), stack, SLOT(setCurrentIndex(int)));
}
开发者ID:Tymolc,项目名称:CG-I-2015,代码行数:34,代码来源:mainwindow.cpp

示例2: QListWidget

/** Creates and sets up list widget.
  * \return Poiter to created list widget.
  * \sa insertItem()
  */
QListWidget *OptionsDialog::createListWidget() {
    QListWidget *listWidget = new QListWidget(this);

    insertItems(listWidget);

    listWidget->setObjectName(QString::fromUtf8("listWidget"));
    listWidget->setMaximumWidth(120);
    listWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
    listWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    listWidget->setFlow(QListView::LeftToRight);
    listWidget->setGridSize(QSize(110, 60));
    listWidget->setViewMode(QListView::IconMode);

    return listWidget;
}
开发者ID:marek629,项目名称:SIR,代码行数:19,代码来源:OptionsDialog.cpp

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

示例4: createEditor

QWidget*  MultiDelegate::createEditor( QWidget* parent,
                                     const QStyleOptionViewItem& option,
                                     const QModelIndex& index)  const
{
    const QAbstractItemModel*  model = index.model();
    QVariant  value = model->data( index, Qt::EditRole);
    switch (value.type()) {
    case QMetaType::QTime:
    {
        QTimeEdit*  editor = new QTimeEdit( parent);
        editor->setMaximumWidth( editor->sizeHint().width());

        //// Get value snapshot into editor
        editor->setTime( value.toTime());
        return editor;
    }
    case QMetaType::QDate:
    {
        QDateEdit*  editor = new QDateEdit( parent);
        setupCalenderWidget( editor);
        editor->setMaximumWidth( editor->sizeHint().width());

        //// Get value snapshot into editor
        editor->setDate( value.toDate());
        return editor;
    }
    case QMetaType::QDateTime:
    {
        QDateTimeEdit*  editor = new QDateTimeEdit( parent);
        setupCalenderWidget( editor);
        editor->setMaximumWidth( editor->sizeHint().width());

        editor->setDateTime( value.toDateTime());
        return editor;
    }
    case QMetaType::QImage:
        // Fall throu
    case QMetaType::QPixmap:
        // Fall throu
    case QMetaType::QIcon:
    {
        PixmapViewer*  editor = new PixmapViewer( parent);
        connect( editor, SIGNAL(finished(int)), this, SLOT(closeEmittingEditor()));
        return editor;
    }
    case QMetaType::QStringList:
    {
        QVariant  varList = index.model()->data( index, ItemDataRole::EnumList);
        if (varList.isNull())  break;  // Not a enum-list, fall to std

        QListWidget*  editor = new QListWidget( parent);
        foreach (const QString& bitItemText, varList.toStringList()) {
            QListWidgetItem* bitItem = new QListWidgetItem( bitItemText, editor);
            bitItem->setFlags(bitItem->flags() | Qt::ItemIsUserCheckable);
            bitItem->setCheckState(Qt::Unchecked);
        }
        int width  = editor->sizeHintForColumn(0) + 25;
        int height = editor->sizeHintForRow(0) * editor->count() + 10;
        editor->setMinimumWidth( width);
        editor->setMaximumWidth( width);
        editor->setMinimumHeight( height);
        editor->setMaximumHeight( height);

        //// Get value snapshot into editor
        QStringList  valList = value.toStringList();
        int  itemCount = editor->count();
        for (int i = 0; i < itemCount; ++i) {
            QListWidgetItem*  bitItem = editor->item(i);
            bool  isActive = valList.contains( bitItem->text());
            bitItem->setCheckState( isActive ? Qt::Checked : Qt::Unchecked);
        }
        return editor;
    }
    case QMetaType::QString:
    {
        QVariant  varList = index.model()->data( index, ItemDataRole::EnumList);
        if (varList.isNull())  break;  // Not a enum-list, fall to std

        QComboBox*  editor = new QComboBox( parent);
        editor->setSizeAdjustPolicy(QComboBox::AdjustToContents);
        editor->addItems( varList.toStringList());
        editor->setMaximumWidth( editor->minimumSizeHint().width());

        //// Get value snapshot into editor
        editor->setCurrentIndex( editor->findText( value.toString()));
        return editor;
    }
    default:;
    }

    if (index.column() == 0) {
        emit itemEditTrigged( index);
        return 0;  // No inline editor
    }

    QWidget*  editor = QItemDelegate::createEditor( parent, option, index);

    //// Get value snapshot into editor
    QItemDelegate::setEditorData( editor, index);
    return editor;
//.........这里部分代码省略.........
开发者ID:micwik,项目名称:ArnBrowser,代码行数:101,代码来源:MultiDelegate.cpp

示例5: QMainWindow

MainWindow::MainWindow(QWidget *parent, QFlag flags)
:   QMainWindow(parent, flags)
{
    // Set window title
    setWindowTitle("3D Computergrafik I - SS2015 - Aufgabenblatt 1");

    // Create main container
    QWidget *container = new QWidget();
    setCentralWidget(container);

    // Add list (on the left)
    QListWidget *list = new QListWidget(container);
    list->addItem("Beispiel");
    list->addItem("Aufgabe 1");
    list->addItem("Aufgabe 2");
    list->addItem("Aufgabe 3");
    list->addItem("Aufgabe 4a");
    list->addItem("Aufgabe 4b");
    list->setMaximumWidth(150);

    // Add stack of exercise windows (on the right)
    QStackedWidget *stack = new QStackedWidget(container);

    // Add exercises
    Exercise123 *orig = new Exercise123(Exercise123::ORIGINAL);

    QList<ImageView*> e1Views;
    e1Views.append(new Exercise123(Exercise123::GRAYSCALE));
    e1Views.append(new Exercise123(Exercise123::INVERT));

    QList<ImageView*> e2Views;
    e2Views.append(new Exercise123(Exercise123::LAPLACE));
    e2Views.append(new Exercise123(Exercise123::GAUSS));
    e2Views.append(new Exercise123(Exercise123::SOBEL));
    e2Views.append(new Exercise123(Exercise123::MEANFILTER));

    Exercise123 *e3 = new Exercise123(Exercise123::DITHERED);

    Exercise4a *e4a = new Exercise4a();
    Exercise4b *e4b = new Exercise4b();


    QWidget *e1Window = createMultiViewWidget(e1Views,orig);
    QWidget *e2Window = createMultiViewWidget(e2Views,orig);

    stack->addWidget(orig);
    stack->addWidget(e1Window);
    stack->addWidget(e2Window);
    stack->addWidget(e3);
    stack->addWidget(e4a);
    stack->addWidget(e4b);

    // Create layout
    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(list);
    layout->addWidget(stack);
    container->setLayout(layout);

    // Connect selection-event of list to select the current visible window
    connect(list, SIGNAL(currentRowChanged(int)), stack, SLOT(setCurrentIndex(int)));
}
开发者ID:Boffmann,项目名称:3D_Grafik,代码行数:61,代码来源:mainwindow.cpp


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