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


C++ QListWidgetItem::sizeHint方法代码示例

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


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

示例1: addMusics

void MusicPage::addMusics(int listId, QQueue<MusicInfo> musics)
{
    MusicInfo musicInfo;
    MusicList *musicList;
    int row;
    while (!musics.empty())
    {
        musicInfo = musics.front();
        musics.pop_front();
        musicList = (MusicList *)musicLists->widget(listId);
        row = musicList->count();
        QListWidgetItem *item = new QListWidgetItem(musicList);
        item->setSizeHint(QSize(item->sizeHint().width(), 30));
        musicList->insertItem(row, item);
        MusicListItem *itemwidget = new MusicListItem(musicList);
        itemwidget->setName(musicInfo.getName());
        itemwidget->setArtist(musicInfo.getArtist());
        musicList->setItemWidget(item, itemwidget);
        /*
        musicList->insertRow(row);
        QTableWidgetItem *nameItem = new QTableWidgetItem(musicInfo.getName());
        QTableWidgetItem *artiseItem = new QTableWidgetItem(musicInfo.getArtist());

        nameItem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
        artiseItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);

        musicList->setItem(row, 0, nameItem);
        musicList->setItem(row, 1, artiseItem);

        musicList->setCurrentCell(row, 0);
        */
    }
}
开发者ID:AndyQsmart,项目名称:QtMusic-1.0,代码行数:33,代码来源:musicpage.cpp

示例2: addMusic

void MusicPage::addMusic(QString name, QString artist)
{
    MusicList *musicList = (MusicList *)musicLists->currentWidget();
    int row = musicList->count();

    QListWidgetItem *item = new QListWidgetItem(musicList);
    item->setSizeHint(QSize(item->sizeHint().width(), 30));
    musicList->insertItem(row, item);
    MusicListItem *itemwidget = new MusicListItem(musicList);
    itemwidget->setName(name);
    itemwidget->setArtist(artist);
    musicList->setItemWidget(item, itemwidget);
    musicList->setCurrentRow(row);
    /*
    musicList->insertRow(row);
    QTableWidgetItem *nameItem = new QTableWidgetItem(name);
    QTableWidgetItem *artiseItem = new QTableWidgetItem(artist);

    nameItem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    artiseItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);

    musicList->setItem(row, 0, nameItem);
    musicList->setItem(row, 1, artiseItem);

    musicList->setCurrentCell(row, 0);
    */
}
开发者ID:AndyQsmart,项目名称:QtMusic-1.0,代码行数:27,代码来源:musicpage.cpp

示例3: initUI

void KbLayoutWidget::initUI() {
    setObjectName("KeyboardLayoutFrame");
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setSelectionMode(QAbstractItemView::NoSelection);
    setResizeMode(Adjust);

    for (int i = 0; i < m_buttons.length(); i++) {
        LayoutButton* itemButton = new LayoutButton(m_buttons[i]);
        m_layoutButtons.append(itemButton);
        itemButton->setFixedSize(widget_width, DDESESSIONCC::LAYOUTBUTTON_HEIGHT);

        QFrame* borderFrame = new QFrame;
        borderFrame->setObjectName("LayoutBorderFrame");
        QVBoxLayout* borderLayout = new QVBoxLayout;
        borderLayout->setContentsMargins(0, 0, 0, 0);
        borderLayout->setSpacing(0);
        borderLayout->addWidget(itemButton);
        borderFrame->setLayout(borderLayout);
        borderFrame->setFixedSize(widget_width, DDESESSIONCC::LAYOUTBUTTON_HEIGHT);

        QListWidgetItem* item = new QListWidgetItem(this);
        item->sizeHint();
        this->addItem(item);
        setItemWidget(item,  borderFrame);
        this->setGridSize(QSize(widget_width, DDESESSIONCC::LAYOUTBUTTON_HEIGHT));
        this->setFixedWidth(widget_width);
    }
    this->setFixedHeight(DDESESSIONCC::LAYOUTBUTTON_HEIGHT*3);



    updateStyle(":/skin/keybdlayoutwidget.qss", this);
}
开发者ID:Kirek,项目名称:deepin-session-ui-manjaro,代码行数:34,代码来源:kblayoutwidget.cpp

示例4: setAvailableParameters

void medLinkMenu::setAvailableParameters(QStringList parameters)
{
    d->availableParams = parameters;

    for(int i=0; i<d->paramList->count();i++)
        d->paramList->model()->removeRow(i);

    QListWidgetItem * item = new QListWidgetItem("All");
    item->setSizeHint(QSize(item->sizeHint().width(), 20));
    item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
    item->setCheckState(Qt::Unchecked);
    d->paramList->insertItem(0,item);

    int i = 1;
    foreach(QString param, parameters)
    {
        QListWidgetItem * item = new QListWidgetItem(param);
        item->setSizeHint(QSize(item->sizeHint().width(), 20));
        item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
        item->setCheckState(Qt::Unchecked);
        d->paramList->insertItem(i,item);
        i++;
    }
开发者ID:Inria-Asclepios,项目名称:medInria-public,代码行数:23,代码来源:medLinkMenu.cpp

示例5: QListWidget

MusicListWidget::MusicListWidget(QWidget *parent) :
    QListWidget(parent)
{
    this->setMouseTracking(true);
    m_musicItem = new MusicItemWidget;

    for(int i = 0; i < 100; ++i)
    {
        QString title = QString("%1-Title abcde - Author - Album<<xxx x>> 2013").arg(i);
        QListWidgetItem* item = new QListWidgetItem(title, this);
        m_itemHeight = item->sizeHint().height();
    }

    connect(this, SIGNAL(itemEntered(QListWidgetItem*)),
            this, SLOT(itemHoverEnter(QListWidgetItem*)) );
    connect(m_musicItem, SIGNAL(mouseLeave(QListWidgetItem*)),
            this, SLOT(itemHoverLeave(QListWidgetItem*)) );
}
开发者ID:newdebug,项目名称:NewDebug,代码行数:18,代码来源:MusicListWidget.cpp

示例6: QListWidget

/************************************************
 *  Widget Listing:
 * Creation of the list of drawed lovely buttons
 ************************************************/
WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent )
              : QListWidget( _parent )
{
    /* We need the parent to know the options checked */
    parent = qobject_cast<ToolbarEditDialog *>(_parent);
    assert( parent );

    /* Normal options */
    setViewMode( QListView::ListMode );
    setTextElideMode( Qt::ElideNone );
    setDragEnabled( true );
    int icon_size = fontMetrics().height();
    setIconSize( QSize( icon_size * 2, icon_size ) );
    /* All the buttons do not need a special rendering */
    for( int i = 0; i < BUTTON_MAX; i++ )
    {
        QListWidgetItem *widgetItem = new QListWidgetItem( this );
        widgetItem->setText( qtr( nameL[i] ) );
        widgetItem->setSizeHint( QSize( widgetItem->sizeHint().width(), 32 ) );

        widgetItem->setIcon( QIcon( iconL[i] ) );
        widgetItem->setData( Qt::UserRole, QVariant( i ) );
        widgetItem->setToolTip( widgetItem->text() );
        addItem( widgetItem );
    }

    /* Spacers are yet again a different thing */
    QListWidgetItem *widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space.svg" ),
            qtr( "Spacer" ), this );
    widgetItem->setData( Qt::UserRole, WIDGET_SPACER );
    widgetItem->setToolTip( widgetItem->text() );
    widgetItem->setSizeHint( QSize( widgetItem->sizeHint().width(), 32 ) );
    addItem( widgetItem );

    widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space.svg" ),
            qtr( "Expanding Spacer" ), this );
    widgetItem->setData( Qt::UserRole, WIDGET_SPACER_EXTEND );
    widgetItem->setToolTip( widgetItem->text() );
    widgetItem->setSizeHint( QSize( widgetItem->sizeHint().width(), 32 ) );
    addItem( widgetItem );

    /**
     * For all other widgets, we create then, do a pseudo rendering in
     * a pixmaps for the view, and delete the object
     *
     * A lot of code is retaken from the Abstract, but not exactly...
     * So, rewrite.
     * They are better ways to deal with this, but I doubt that this is
     * necessary. If you feel like you have the time, be my guest.
     * --
     * jb
     **/
    for( int i = SPLITTER; i < SPECIAL_MAX; i++ )
    {
        QWidget *widget = NULL;
        QListWidgetItem *widgetItem = new QListWidgetItem;
        widgetItem->setSizeHint( QSize( widgetItem->sizeHint().width(), 32 ) );
        switch( i )
        {
        case SPLITTER:
            {
                QFrame *line = new QFrame( this );
                line->setFrameShape( QFrame::VLine );
                line->setFrameShadow( QFrame::Raised );
                line->setLineWidth( 0 ); line->setMidLineWidth( 1 );
                widget = line;
            }
            widgetItem->setText( qtr("Splitter") );
            break;
        case INPUT_SLIDER:
            {
                SeekSlider *slider = new SeekSlider( p_intf, Qt::Horizontal, this );
                widget = slider;
            }
            widgetItem->setText( qtr("Time Slider") );
            break;
        case VOLUME:
            {
                SoundWidget *snd = new SoundWidget( this, p_intf,
                        parent->getOptions() & WIDGET_SHINY );
                widget = snd;
            }
            widgetItem->setText( qtr("Volume") );
            break;
        case VOLUME_SPECIAL:
            {
                QListWidgetItem *widgetItem = new QListWidgetItem( this );
                widgetItem->setText( qtr("Small Volume") );
                widgetItem->setIcon( QIcon( ":/toolbar/volume-medium.svg" ) );
                widgetItem->setData( Qt::UserRole, QVariant( i ) );
                addItem( widgetItem );
            }
            continue;
        case TIME_LABEL:
            {
                QLabel *timeLabel = new QLabel( "12:42/2:12:42", this );
//.........这里部分代码省略.........
开发者ID:videolan,项目名称:vlc,代码行数:101,代码来源:toolbar.cpp

示例7: paintEvent

/** Redefined to be able to display items with the current theme. */
void AddressBarMenu::paintEvent(QPaintEvent *)
{
	QStylePainter p(this->viewport());
	// Vertical frame between icons and text
	p.save();
	QPalette palette = QApplication::palette();
	p.setPen(palette.midlight().color());
	p.drawLine(33, 0, 33, rect().height());
	p.restore();

	int offsetSB = 0;
	if (verticalScrollBar()->isVisible()) {
		offsetSB = verticalScrollBar()->width() - 1;
	}

	// Subdirectories in the popup menu
	for (int i = 0; i < count(); i ++) {
		QListWidgetItem *it = item(i);
		QRect r = this->visualItemRect(it);
		/// FIXME
		//QSize s = it->sizeHint();
		//QRect r(0, i * s.height(), );
		//qDebug() << "r" << r;
		r.setWidth(r.width() - offsetSB);

		if (it->data(Qt::UserRole + 1).toBool()) {
			p.save();
			p.setPen(palette.midlight().color());
			p.drawLine(r.x(), r.y() + (it->sizeHint().height()) / 2, r.width(), r.y() + (it->sizeHint().height()) / 2);
			p.restore();
			continue;
		}

		r.adjust(1, 1, -4, -1);
		bool isHighlighted = r.contains(mapFromGlobal(QCursor::pos()));
		// Draw: Highlight, Icon, Text
		if (r.isValid()) {
			QRect iconRect(r.x() + 6, r.y() + 2, 19, 19);
			bool itemIsEnabled = true;
			if (it->flags().testFlag(Qt::NoItemFlags)) {
				p.drawPixmap(iconRect, it->icon().pixmap(QSize(19, 19), QIcon::Disabled));
				itemIsEnabled = false;
			} else {
				p.save();
				if (isHighlighted) {
					p.setPen(palette.highlight().color());
					p.setBrush(palette.highlight().color().lighter());
					p.drawRect(r);
					p.setPen(QColor(192, 192, 192, 128));
					p.drawLine(33, r.top() + 1, 33, r.bottom());
				}
				p.restore();
				p.drawPixmap(iconRect, it->icon().pixmap(QSize(19, 19)));
			}

			QRect textRect = r.adjusted(37, 0, 0, 0);
			QString text = fontMetrics().elidedText(it->text(), Qt::ElideRight, textRect.width());
			p.save();

			p.setFont(it->font());
			QColor lighterBG = palette.highlight().color().lighter();
			QColor highlightedText = palette.highlightedText().color();
			if (itemIsEnabled && isHighlighted && qAbs(lighterBG.saturation() - highlightedText.saturation()) > 128) {
				p.setPen(highlightedText);
			} else {
				if (itemIsEnabled) {
					p.setPen(palette.text().color());
				} else {
					p.setPen(palette.color(QPalette::Disabled, QPalette::WindowText));
				}
			}

			p.drawText(textRect, text, Qt::AlignLeft | Qt::AlignVCenter);
			p.restore();
		}
	}
}
开发者ID:arnolddumas,项目名称:Miam-Player,代码行数:78,代码来源:addressbarmenu.cpp

示例8: draw

void MainWindow::draw(QString dataDir, ColorMap::FILE_TYPE filetype)
{
    switch (filetype) {
    case ColorMap::PMPL:
//        qDebug()<<getFiletypeFromFileDir(dataDir);
        if(getFiletypeFromFileDir(dataDir) != ".pmpl")
            return;
        if(getDrawn(0))
            return;
        break;
    case ColorMap::CLH:
        if(getFiletypeFromFilePath(dataDir) != ".clh")
            return;
        if(getDrawn(1))
            return;
        break;
    case ColorMap::EXT:
        if(getFiletypeFromFileDir(dataDir) != ".ext")
            return;
        if(getDrawn(2))
            return;
        break;
    case ColorMap::LAYER:
        if(getFiletypeFromFilePath(dataDir) != ".layer")
            return;
        if(getDrawn(3))
            return;
        break;
    case ColorMap::UGM3:
        if(getFiletypeFromFileDir(dataDir) != ".ugm3")
            return;
        if(getDrawn(4))
            return;
        break;
    case ColorMap::PMPLR:
        if(getFiletypeFromFileDir(dataDir) != ".pmplr")
            return;
        if(getDrawn(5))
            return;
        break;
    default:
        break;
    }

    MapWindow *mp = new MapWindow(this);
//    qDebug()<<this;
    mp->setFiletype(filetype);
    mp->plot(dataDir, filetype, isRealTime);
    mp->setFixedSize(mp->width(),mp->height());

    QListWidgetItem* item = new QListWidgetItem(ui->listWidget);
    item->setSizeHint(QSize(item->sizeHint().width(),mp->height()));
    ui->listWidget->addItem(item);

    ui->listWidget->setItemWidget(item, mp);
//    qDebug()<<mp->parent()->parent()->parent()->parent()->parent()->parent()->parent();

    switch (filetype) {
    case ColorMap::PMPL:
            setDrawn(0, true);
            break;
    case ColorMap::CLH:
        setDrawn(1, true);
            break;
    case ColorMap::EXT:
        setDrawn(2, true);
            break;
    case ColorMap::LAYER:
        setDrawn(3, true);
            break;
    case ColorMap::UGM3:
        setDrawn(4, true);
            break;
    case ColorMap::PMPLR:
        setDrawn(5, true);
            break;
    default:
        break;
    }

}
开发者ID:lightjameslyy,项目名称:hefei_project_runnable_windows,代码行数:81,代码来源:mainwindow.cpp


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