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


C++ QLabel::adjustSize方法代码示例

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


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

示例1: createUi

  void createUi(PlotViewInterpolation* plot_view) {
    _b1_rbtn = new QRadioButton("no boundary", plot_view);
    _b2_rbtn = new QRadioButton("c1 boundary", plot_view);
    _b3_rbtn = new QRadioButton("c2 boundary", plot_view);
    _b1_rbtn->setDown(true);

    _lbl_weight = new QLabel("lambda", plot_view);
    _lbl_weight->setAlignment(Qt::AlignRight);
    _lbl_weight->adjustSize();

    _sld_precision = new QSlider(Qt::Horizontal, plot_view);
    _sld_precision->setMinimum(1);
    _sld_precision->setMaximum(1000);
    _sld_precision->setTickInterval(1);
    _sld_precision->setValue(20);
    _sld_precision->adjustSize();

    _sld_alpha = new QSlider(Qt::Horizontal, plot_view);
    _sld_alpha->setMinimum(1);
    _sld_alpha->setMaximum(1000);
    _sld_alpha->setTickInterval(1);
    _sld_alpha->setValue(50);
    _sld_alpha->adjustSize();

    _lbl_knot = new QLabel("initial knots", plot_view);
    _lbl_knot->setAlignment(Qt::AlignRight);
    _lbl_knot->adjustSize();

    _lbl_level = new QLabel("level", plot_view);
    _lbl_level->setAlignment(Qt::AlignRight);
    _lbl_knot->adjustSize();

    _sld_level = new QSlider(Qt::Horizontal, plot_view);
    _sld_level->setMinimum(1);
    _sld_level->setMaximum(10);
    _sld_level->setTickInterval(1);
    _sld_level->setValue(1);
    _sld_level->adjustSize();

    QSignalMapper* signal_map = new QSignalMapper(plot_view);
    signal_map->setMapping(_b1_rbtn, 0);  // no boundary
    signal_map->setMapping(_b2_rbtn, 1);  // c1 boundary
    signal_map->setMapping(_b3_rbtn, 2);  // c2 boundary

    QObject::connect(_b1_rbtn, SIGNAL(clicked()), signal_map, SLOT(map()));
    QObject::connect(_b2_rbtn, SIGNAL(clicked()), signal_map, SLOT(map()));
    QObject::connect(_b3_rbtn, SIGNAL(clicked()), signal_map, SLOT(map()));
    QObject::connect(signal_map, SIGNAL(mapped(int)), plot_view,
                     SLOT(setBoundary(int)));
    QObject::connect(_sld_precision, &QSlider::valueChanged, plot_view,
                     &PlotViewInterpolation::changePrecision);
    QObject::connect(_sld_alpha, &QSlider::valueChanged, plot_view,
                     &PlotViewInterpolation::changeAlpha);
    QObject::connect(_sld_level, &QSlider::valueChanged, plot_view,
                     &PlotViewInterpolation::changeLevel);
  }
开发者ID:litlpoet,项目名称:interpolation,代码行数:56,代码来源:plotviewinterpolation.cpp

示例2: initialize

bool ImagePlugin::initialize( KIO::RenameDlg_Mode mode, const QString &_src, const QString &_dest,
		  const QString &/*mimeSrc*/,
		  const QString &/*mimeDest*/,
		  KIO::filesize_t /*sizeSrc*/,
		  KIO::filesize_t /*sizeDest*/,
		  time_t /*ctimeSrc*/,
		  time_t /*ctimeDest*/,
		  time_t /*mtimeSrc*/,
		  time_t /*mtimeDest*/ ) 
{
  QGridLayout *lay = new QGridLayout(this, 2, 3, 5  );
  if( mode & KIO::M_OVERWRITE )
  {
    QLabel *label = new QLabel(this );
    label->setText(i18n("You want to overwrite the left picture with the one on the right.") );
    label->adjustSize();
    lay->addMultiCellWidget(label, 1, 1, 0, 2,  Qt::AlignHCenter  );
    adjustSize();
  }
  ImageVisualizer *left= new ImageVisualizer(this, "Visualizer Left", _dest );
  ImageVisualizer *right = new ImageVisualizer( this, "Visualizer Right", _src );
  lay->addWidget(left, 2, 0 );
  lay->addWidget(right, 2, 2 );
  adjustSize();
  return true;
}
开发者ID:iegor,项目名称:kdesktop,代码行数:26,代码来源:image_plugin.cpp

示例3: displayLabels

void PlotScene::displayLabels(const QPointF& mousePos, const QPointF& scenePos)
{
    QPalette palette;
    PlotCurve* currentCurve = NULL;

    for (int i(0); i < this->curves.count(); i++)
    {
        currentCurve = this->curves.at(i);

        /* Get the CoordinateItem which abscisse is the nearest
         * to the mouse position abscisse */
        CoordinateItem* itemAtMousePos =
                currentCurve->nearestCoordinateitemsOfX(scenePos.x());

        if (itemAtMousePos == NULL) continue;

        // Get the label associate to the curve
        QLabel* curveLabel = this->curveLabels.at(i);
        if (curveLabel == NULL) continue;

        // Change the text color of the label associate to the curve
        palette.setColor(QPalette::WindowText, currentCurve->getPen().color());
        curveLabel->setPalette(palette);

        // Change the text of the label associate to the curve
        curveLabel->setText(QString("%1, %2").arg(
                                itemAtMousePos->x(), 6, 'f', 2).arg(
                                itemAtMousePos->y(), 6, 'f', 2));
        curveLabel->adjustSize();

        // Move the label
        curveLabel->move(mousePos.x(), mousePos.y() - (i * 12));
    }
}
开发者ID:xaviermawet,项目名称:EcoManager2013,代码行数:34,代码来源:PlotScene.cpp

示例4: SLOT

void
MessageBar::show( const QString& message, const QString& id )
{    
    QLabel* label = findChild<QLabel*>( id );
    
    if (label && id.size()) {
        if (message.isEmpty())
        {
            QProgressBar* p = label->findChild<QProgressBar*>();
            if (p)
                p->setRange( 0, 1 ),
                p->setValue( 1 );
            QTimer::singleShot( 3000, label, SLOT(deleteLater()) );
        }
        else
            label->setText( message );
        return;
    }
    
    label = new QLabel( message, ui.papyrus );
    label->setBackgroundRole( QPalette::Base );
    label->setMargin( 8 );
    label->setIndent( 4 );
    label->setTextFormat( Qt::RichText );
    label->setOpenExternalLinks( true );
    label->setTextInteractionFlags( Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse );
    
    ImageButton* close = new ImageButton( ":/buckets/radio_clear_all_x.png" );
    QHBoxLayout* h = new QHBoxLayout( label );
    h->addStretch();
    
    if (id.size())
    {
        label->setObjectName( id );
        
        QProgressBar* p;
        h->addWidget( p = new QProgressBar );
        p->setRange( 0, 0 );
        p->setFixedWidth( 90 );
    }

    h->addWidget( close );
    h->setMargin( 4 );
    
    label->setFixedWidth( width() );
    label->adjustSize();
    label->show();
    
    ui.papyrus->move( 0, -label->height() );

    doLayout();
    
    connect( close, SIGNAL(clicked()), label, SLOT(deleteLater()) );    
    connect( label, SIGNAL(destroyed()), SLOT(onLabelDestroyed()), Qt::QueuedConnection );
        
    m_timeline->setFrameRange( height(), ui.papyrus->height() );
    m_timeline->start();
}
开发者ID:RJ,项目名称:lastfm-desktop,代码行数:58,代码来源:MessageBar.cpp

示例5: printVictimImage

/**
 * @brief MapManager::printVictimImage slot chiamato quando il robot trova una vittima
 * @param cvImage l'immagine da mostrare
 */
void MapManager::printVictimImage(cv::Mat cvImage)
{
    QImage image = Mat2QImage(cvImage);

    QLabel *victimImage = new QLabel();
    victimImage->setPixmap(QPixmap::fromImage((image)));
    victimImage->adjustSize();

    layout->addWidget(victimImage);
}
开发者ID:FrancescoDesogus,项目名称:RoboticaAIBO,代码行数:14,代码来源:mapmanager.cpp

示例6: computationCompleted

void GCOutputWindow::computationCompleted(QImage result)
{
  QLabel* imagelabel = new QLabel(this);
  imagelabel->setBackgroundRole(QPalette::Base);
  imagelabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
  imagelabel->setPixmap(QPixmap::fromImage(result));
  imagelabel->adjustSize();

  QScrollArea* scrollview = new QScrollArea(this);
  scrollview->setWidget(imagelabel);

  m_OutputTabView->addTab(scrollview, "Mask");
  m_OutputTabView->setCurrentWidget(scrollview);
  m_OutputStackView->setCurrentIndex(1);
}
开发者ID:davll,项目名称:vfx2014,代码行数:15,代码来源:GCOutputWindow.cpp

示例7: PasswordDialog

PasswordDialog *PasswordDialog::getPassword(QWidget *parent, const QString &windowTitle, const QString &description,
                                            const QString &errorMessage)
{
    auto d = new PasswordDialog(parent);
    d->setWindowTitle(windowTitle);
    d->ui.descriptionLabel->setText(description);
    d->ui.passwordLineEdit->setEchoMode(QLineEdit::Password);

    // fight the word wrapping beast, also see below
    int l,r,t,b; // we're gonna need the horizontal margins
    d->ui.verticalLayout->getContentsMargins(&l,&t,&r,&b);
    QList<QLabel*> fixedLabels; // and the labels we adjusted

    // 1. fix the dialog width, assuming to be wanted.
    d->setMinimumWidth(d->width());
    // 2. fix the label width
    fixedLabels << d->ui.descriptionLabel;
    // NOTICE: d->ui.descriptionLabel is inside a grid layout, which however has 0 margins
    d->ui.descriptionLabel->setMinimumWidth(d->width() - (l+r));
    // 3. have QLabel figure the size for that width and the content
    d->ui.descriptionLabel->adjustSize();
    // 4. make the label a fixed size element
    d->ui.descriptionLabel->setFixedSize(d->ui.descriptionLabel->size());
    d->adjustSize();

    if (!errorMessage.isEmpty()) {
        QLabel *errorLabel = new QLabel(d);
        d->ui.verticalLayout->insertWidget(0, errorLabel);
        errorLabel->setWordWrap(true);
        errorLabel->setText(errorMessage + QLatin1String("\n<hr>"));
        errorLabel->setTextFormat(Qt::RichText);

        // wordwrapping labels are a problem of its own
        fixedLabels << errorLabel;
        errorLabel->setMinimumWidth(d->width() - (l+r));
        errorLabel->adjustSize();
        errorLabel->setFixedSize(errorLabel->size());
    }

    d->adjustSize();
    d->setMinimumWidth(0);
    foreach(QLabel *label, fixedLabels) {
        label->setMinimumSize(0, 0);
        label->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
    }
开发者ID:KDE,项目名称:trojita,代码行数:45,代码来源:PasswordDialog.cpp

示例8: initUI

void se_kbmwidget::initUI()
{
    this->setWindowIcon(QIcon(":/img/Logo"));
    //this->setWindowFlags(Qt::Tool | Qt::X11BypassWindowManagerHint);
    this->setGeometry(QRect(380,140,650,400));
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->setModal(true);
    m_backgroundWidget = new Kbmbasewidget(this);
    m_backgroundWidget->setGeometry(rect());
    m_backgroundWidget->lower();
    QLabel *logoLabel = new QLabel;
    logoLabel->setPixmap(QPixmap(":/img/logo"));//logo
    QLabel *textLabel = new QLabel;
    textLabel->setText("OS 测评之家 1.0");//界面tital
    textLabel->setStyleSheet("color:white;");
    textLabel->adjustSize();
    QHBoxLayout *hLayout = new QHBoxLayout;//左上角布局
    hLayout->addWidget(logoLabel);
    hLayout->addWidget(textLabel);
    stack = new QStackedWidget;
    buttonGroup = new SysButtonGroup;//右上角按钮组
    connect(buttonGroup, SIGNAL(closeWidget()), this, SIGNAL(closeWidget()));
    QWidget *title = new QWidget;//顶部第一页面
    title->setAttribute(Qt::WA_TranslucentBackground);
    title->setLayout(hLayout);

    kbm = new MainKBMview;//显示页面
    wait = new LoadingDialog;//等待页面

    stack->addWidget(wait);
    stack->addWidget(kbm);

    QHBoxLayout *titleLayout = new QHBoxLayout;
    titleLayout->addWidget(title, 0, Qt::AlignLeft | Qt::AlignTop);
    titleLayout->addStretch();
    titleLayout->addWidget(buttonGroup, 0, Qt::AlignRight | Qt::AlignTop);
    titleLayout->setContentsMargins(10, 0, 0, 0);

    QVBoxLayout *vLayout = new QVBoxLayout;
    vLayout->addLayout(titleLayout);
    vLayout->addWidget(stack);
    vLayout->setSpacing(0);
    vLayout->setContentsMargins(0,0,0,0);
    this->setLayout(vLayout);
}
开发者ID:polefishu,项目名称:OSbenchmark,代码行数:45,代码来源:se_kbmwidget.cpp

示例9: handle

void ImagePlugin::handle( KIO::RenameDialog_Mode mode, const KIO::RenameDialogPlugin::FileItem& src,
                          const KIO::RenameDialogPlugin::FileItem& dst ) {
    QGridLayout *lay = new QGridLayout( this );
    if( mode & KIO::M_OVERWRITE ) {
        QLabel *label = new QLabel(this );
        label->setText(i18n("You want to overwrite the left picture with the one on the right.") );
        label->adjustSize();
        lay->addWidget(label, 1, 0, 1, 3, Qt::AlignHCenter );
        adjustSize();
    }

    ImageVisualizer *left= new ImageVisualizer(this, dst.url() );
    ImageVisualizer *right = new ImageVisualizer( this, src.url() );

    lay->addWidget(left, 2, 0 );
    lay->addWidget(right, 2, 2 );
    adjustSize();
}
开发者ID:KDE,项目名称:kde-runtime,代码行数:18,代码来源:image_plugin.cpp

示例10: QLabel

QLabel *HUD2::InitLabel( int x, int y, int h, QString text, QColor c )
{
   QLabel *lab = new QLabel( this );
   //QFont     f = QFont( "Courier", h );
   QFont     f = QFont( "Vera", h );
   f.setBold( true );
   QPalette  p = lab->palette();
   
   p.setColor( QPalette::WindowText, c );

   lab->setGeometry( x, y, 0, 0 );
   lab->setPalette( p );
   lab->setFont(f);
   lab->setText(text);
   lab->adjustSize();

   return lab;
}
开发者ID:barthess,项目名称:volat3,代码行数:18,代码来源:Window.cpp

示例11: updateProgressBar

void Progression::updateProgressBar(QString file, qint64 pos, QString currentFile){
	ProgressBars[file]->setValue((int) pos);
	qDebug() << "Update" << vbl->count();
	if(currentFile != "")
	{
		for(int i = 0; i < vbl->count(); i++)
		{
			QLayoutItem* item = vbl->itemAt(i);
			QWidget* widget = item->widget();
			if (widget) {
				QLabel *label = qobject_cast<QLabel *>(widget);
				if(label->text().contains(file))
				{
					label->setText(file + " -> " + currentFile);
					label->adjustSize();
				}
			}
		}
	}
	this->adjustSize();
}
开发者ID:ThomasAy,项目名称:Duplicateur,代码行数:21,代码来源:Progression.cpp

示例12: escreve

void JanelaOpcoes::escreve() {
    QLabel *lbl;

    lbl = new QLabel("Curva:", tela);
    lbl->setGeometry(10, 15, 0, 0); lbl->adjustSize();
    lbl->show();

    lbl = new QLabel("Cor:", tela);
    lbl->setGeometry(40, 45, 0, 0); lbl->adjustSize();
    lbl->show();

    lbl = new QLabel("R:", tela);
    lbl->setGeometry(85, 45, 0, 0); lbl->adjustSize();
    lbl->show();

    lbl = new QLabel("G:", tela);
    lbl->setGeometry(180, 45, 0, 0); lbl->adjustSize();
    lbl->show();

    lbl = new QLabel("B:", tela);
    lbl->setGeometry(275, 45, 0, 0); lbl->adjustSize();
    lbl->show();

    for(int i = 0 ; i < 3 ; i++) {
        sb_corcurva[i] = new QSpinBox(tela);
        sb_corcurva[i]->setRange(0, 255);
        sb_corcurva[i]->setValue(def->cor_curva[i]);
        sb_corcurva[i]->setGeometry(100 + 95*i, 40, 0, 0); sb_corcurva[i]->adjustSize();
    }

    lbl = new QLabel("Largura:", tela);
    lbl->setGeometry(40, 85, 0, 0); lbl->adjustSize();
    lbl->show();

    sb_larguracurva = new QSpinBox(tela);
    sb_larguracurva->setRange(0, 10);
    sb_larguracurva->setValue(def->w_curva);
    sb_larguracurva->setGeometry(107, 80, 0, 0); sb_larguracurva->adjustSize();

    lbl = new QLabel("Ponto:", tela);
    lbl->setGeometry(10, 125, 0, 0); lbl->adjustSize();
    lbl->show();

    lbl = new QLabel("Cor:", tela);
    lbl->setGeometry(40, 155, 0, 0); lbl->adjustSize();
    lbl->show();

    lbl = new QLabel("R:", tela);
    lbl->setGeometry(85, 155, 0, 0); lbl->adjustSize();
    lbl->show();

    lbl = new QLabel("G:", tela);
    lbl->setGeometry(180, 155, 0, 0); lbl->adjustSize();
    lbl->show();

    lbl = new QLabel("B:", tela);
    lbl->setGeometry(275, 155, 0, 0); lbl->adjustSize();
    lbl->show();

    for(int i = 0 ; i < 3 ; i++) {
        sb_corponto[i] = new QSpinBox(tela);
        sb_corponto[i]->setRange(0, 255);
        sb_corponto[i]->setValue(def->cor_ponto[i]);
        sb_corponto[i]->setGeometry(100 + 95*i, 150, 0, 0); sb_corponto[i]->adjustSize();
    }

    lbl = new QLabel("Largura:", tela);
    lbl->setGeometry(40, 195, 0, 0); lbl->adjustSize();
    lbl->show();

    sb_larguraponto = new QSpinBox(tela);
    sb_larguraponto->setRange(0, 10);
    sb_larguraponto->setValue(def->w_ponto);
    sb_larguraponto->setGeometry(107, 190, 0, 0); sb_larguraponto->adjustSize();

    lbl = new QLabel("Ponto Tangente:", tela);
    lbl->setGeometry(10, 235, 0, 0); lbl->adjustSize();
    lbl->show();

    lbl = new QLabel("Cor:", tela);
    lbl->setGeometry(40, 265, 0, 0); lbl->adjustSize();
    lbl->show();

    lbl = new QLabel("R:", tela);
    lbl->setGeometry(85, 265, 0, 0); lbl->adjustSize();
    lbl->show();

    lbl = new QLabel("G:", tela);
    lbl->setGeometry(180, 265, 0, 0); lbl->adjustSize();
    lbl->show();

    lbl = new QLabel("B:", tela);
    lbl->setGeometry(275, 265, 0, 0); lbl->adjustSize();
    lbl->show();

    for(int i = 0 ; i < 3 ; i++) {
        sb_cortangente[i] = new QSpinBox(tela);
        sb_cortangente[i]->setRange(0, 255);
        sb_cortangente[i]->setValue(def->cor_tangente[i]);
        sb_cortangente[i]->setGeometry(100 + 95*i, 260, 0, 0); sb_cortangente[i]->adjustSize();
//.........这里部分代码省略.........
开发者ID:rengenesio,项目名称:Bezier,代码行数:101,代码来源:janelaopcoes.cpp

示例13: QWidget

PlaylistWidget::PlaylistWidget( QWidget *parent ) :
    QWidget( parent )
{
    //////////////////////////////////////////////////////////////////
    QLabel *databaseFilterLabel;
    QLineEdit *databaseFilter;

    databaseFilterLabel = new QLabel();
    databaseFilterLabel->setText( "Search" );
    databaseFilterLabel->setMinimumWidth( 125 );
    databaseFilterLabel->adjustSize();
    databaseFilter = new QLineEdit();

    QHBoxLayout *searchbar = new QHBoxLayout();
    searchbar->addWidget( databaseFilterLabel );
    searchbar->addWidget( databaseFilter );
    //////////////////////////////////////////////////////////////////

    this->playlistTableModel = new PlaylistTableModel();
    this->playlistTableView = new PlaylistTableView();

    //////////////////////////////////////////////////////////////////
    TrackDelegate * trackDelegate = new TrackDelegate();
    trackDelegate->setPlayIcon( style()->standardIcon( QStyle::SP_MediaPlay ) );
    trackDelegate->setPauseIcon( style()->standardIcon( QStyle::SP_MediaPause ) );

    //////////////////////////////////////////////////////////////////
    this->playlistTableView->setItemDelegate( trackDelegate );
    this->playlistTableView->setModel( this->playlistTableModel );
    this->playlistTableView->setAlternatingRowColors( true );
    this->playlistTableView->setSelectionBehavior( QAbstractItemView::SelectRows );
    this->playlistTableView->setEditTriggers( QAbstractItemView::NoEditTriggers );
    // D&D
    this->playlistTableView->setSelectionMode( QAbstractItemView::ExtendedSelection );
    this->playlistTableView->setDragEnabled( true );
    this->playlistTableView->setAcceptDrops( true );
    this->playlistTableView->setDropIndicatorShown( true );

    //////////////////////////////////////////////////////////////////

    connect( this->playlistTableView,
        SIGNAL( playTrack( const Track * ) ),
        playerengine, SLOT( slotPlayTrack( const Track * ) ) );
    connect(
        playerengine, SIGNAL( updateTrack( const Track * ) ),
        this->playlistTableView, SLOT( slotDisplayTrack( const Track * ) )
    );

    connect(
        this->playlistTableModel, SIGNAL( scrollToCurrentTrack(const QModelIndex &) ),
        this, SLOT( slotScrollToCurrentTrack(const QModelIndex &) )
    );

    connect(    eventmanager, SIGNAL( internetEvent(QVariantMap)),
                this, SLOT( slotInternetEvent(QVariantMap)));

    //////////////////////////////////////////////////////////////////

    connect(    databaseFilter, SIGNAL( textEdited(QString)),
                this, SLOT( slotTextEdited(QString)));

    //////////////////////////////////////////////////////////////////

    QVBoxLayout *mainLayout = new QVBoxLayout();
    mainLayout->addWidget( this->playlistTableView );
    mainLayout->addLayout( searchbar );

    //////////////////////////////////////////////////////////////////

    this->setLayout( mainLayout );

    // HOTKEYS ///////////////////////////////////////////////////////

}
开发者ID:ewasser,项目名称:wave-player,代码行数:74,代码来源:PlaylistWidget.cpp

示例14: QWidget

/**
 * Constructor of the class
 * @param parent
 * @param name
 * @return
 */
NMGModuleToolBoxItem::NMGModuleToolBoxItem( QWidget *parent, QString modName, const QColor & backgroundColor )
		: QWidget( parent )
{
	setObjectName( modName );
	setMouseTracking( true );

	QPalette palette;
	palette.setColor( backgroundRole(), backgroundColor );
	setPalette( palette );

	moduleName = modName;

	QVBoxLayout * layoutVertical = new QVBoxLayout( this );
	layoutVertical->setMargin( 0 );
	layoutVertical->setSpacing( 0 );
	layoutVertical->setObjectName( moduleName + "LayoutVertical" );

	QHBoxLayout * layoutHoritzontal = new QHBoxLayout( 0 );
	layoutHoritzontal->setMargin( 0 );
	layoutHoritzontal->setSpacing( 0 );
	layoutHoritzontal->setObjectName( moduleName + "LayoutHoritzontal" );

	QSpacerItem * leftSpacer = new QSpacerItem( 1, 21, QSizePolicy::Maximum, QSizePolicy::Minimum );
	layoutHoritzontal->addItem( leftSpacer );

	QString toolTip = (( NMGModuleParent * ) NMGModuleManager::self()->getModule( moduleName ) )->getModuleToolTip().c_str();

	QLabel * pixmapLabel1 = new QLabel( this );
	pixmapLabel1->setMaximumSize( QSize( 64, 64 ) );
	pixmapLabel1->setAlignment( Qt::AlignHCenter );
	pixmapLabel1->setObjectName( moduleName + "Label" );

	if ( !toolTip.isEmpty() )
	{
		pixmapLabel1->setToolTip( toolTip );
		pixmapLabel1->setWhatsThis( toolTip );
	}

	QString iconFile = (( NMGModuleParent * ) NMGModuleManager::self()->getModule( moduleName ) )->getModuleIcon().c_str();
	if ( iconFile.isEmpty() ) iconFile = DEFAULT_ICON_NAME;
	pixmapLabel1->setPixmap( * ( NMGImageManager::loadPixmap( iconFile ) ) );
	pixmapLabel1->setScaledContents( TRUE );
	layoutHoritzontal->addWidget( pixmapLabel1 );
	pixmapLabel1->setMouseTracking( true );

	QSpacerItem * rightSpacer = new QSpacerItem( 1, 21, QSizePolicy::Maximum, QSizePolicy::Minimum );
	layoutHoritzontal->addItem( rightSpacer );
	layoutVertical->addLayout( layoutHoritzontal );


	QLabel * txtModuleLabel = new QLabel( "<p align=\"center\">" + moduleName + "</p>", this );
	txtModuleLabel->setObjectName( moduleName + "Label" );
	if ( !toolTip.isEmpty() )
	{
		txtModuleLabel->setToolTip( toolTip );
		txtModuleLabel->setWhatsThis( toolTip );
	}

	QSizePolicy policy1( QSizePolicy::Preferred, QSizePolicy::Preferred );
	policy1.setHorizontalStretch( 0 );
	policy1.setVerticalStretch( 0 );
	policy1.setHeightForWidth( txtModuleLabel->sizePolicy().hasHeightForWidth() );
	txtModuleLabel->setSizePolicy( policy1 );

	/** Size of the label for the plugin's name at toolbar **/
	txtModuleLabel->adjustSize(); //setMaximumSize( QSize( 100, 150 ) );
	QPalette palettelabel;
	palettelabel.setColor( txtModuleLabel->backgroundRole(), backgroundColor );
	txtModuleLabel->setPalette( palettelabel );
	txtModuleLabel->setAlignment( Qt::AlignVCenter ); //how to 'or' with Qt::TextWordWrap ??
	layoutVertical->addWidget( txtModuleLabel );
}
开发者ID:Shwe-123,项目名称:netmeter,代码行数:78,代码来源:nmgmoduletoolboxitem.cpp

示例15: it

KFontChooser::KFontChooser( QWidget *parent, const char *name )
	: QWidget( parent, name )
{
	int i;
	
	fnt = QFont( "helvetica", 12 );
	changed = False;
	
	QBoxLayout *topLayout = new QVBoxLayout( this, 10, 5 );
	topLayout->addStretch( 5 );
	
	QBoxLayout *stackLayout = new QVBoxLayout( 4 );
	
	topLayout->addLayout( stackLayout );
		
	cmbFont = new QComboBox( false, this );
	cmbFont->setFixedHeight( cmbFont->sizeHint().height() );
	
	getFontList( fixedList, true );
	getFontList( fontList );
	
	cmbFont->insertStrList( &fontList );
	QStrListIterator it( fontList );
	for ( i = 0; it.current(); ++it, i++ ) {
		if ( !strcmp( fnt.family(), it.current() ) )
			cmbFont->setCurrentItem( i );
	}
	
	connect( cmbFont, SIGNAL( activated( const char * ) ),
		SLOT( slotSelectFont( const char * ) ) );
		
	QLabel *label = new QLabel( cmbFont, i18n("&Typeface"), this );
	label->adjustSize();
	label->setMinimumSize( label->size() );
	
	stackLayout->addWidget( label );
	stackLayout->addWidget( cmbFont );

	cbBold = new QCheckBox(  i18n("&Bold"), this );
	cbBold->setMinimumSize( cbBold->sizeHint() );
	cbBold->setChecked( fnt.bold() );
	connect( cbBold, SIGNAL( toggled( bool ) ), SLOT( slotFontBold( bool ) ) );
	
	topLayout->addWidget( cbBold );
	
	cbItalic = new QCheckBox(  i18n("&Italic"), this );
	cbItalic->setMinimumSize( cbItalic->sizeHint() );
	cbItalic->setChecked( fnt.italic() );
	connect( cbItalic, SIGNAL( toggled( bool ) ), SLOT( slotFontItalic( bool ) ) );
	
	topLayout->addWidget( cbItalic );
	
	QBoxLayout *pushLayout = new QHBoxLayout(  2 );
	
	topLayout->addLayout( pushLayout );
	
	stackLayout = new QVBoxLayout( 4 );
	
	pushLayout->addLayout( stackLayout, 10 );
	pushLayout->addSpacing( 10 );
	
	sbSize = new KNumericSpinBox( this );
	
	sbSize->setStep( 1 );
	sbSize->setRange( 8, 16 );
	sbSize->setValue( 12 );
	sbSize->adjustSize();

	connect( sbSize, SIGNAL( valueDecreased() ),
		 SLOT( slotFontSize() ) );
		 
	connect( sbSize, SIGNAL( valueIncreased() ),
		 SLOT( slotFontSize() ) );
	
	label = new QLabel( sbSize, i18n("&Size"), this );
	label->setMinimumSize( label->sizeHint() );

	cmbCharset = new QComboBox( false, this );
	
	cmbCharset->adjustSize();
	cmbCharset->setInsertionPolicy( QComboBox::NoInsertion );
	connect( cmbCharset, SIGNAL( activated( const char * ) ),
		 SLOT( slotCharset( const char * ) ) );
	
	sbSize->setFixedHeight( cmbCharset->height() );
	sbSize->setMinimumWidth(sbSize->width());
	cmbCharset->setFixedHeight( cmbCharset->height() );
	cmbCharset->setMinimumWidth( cmbCharset->width());

	stackLayout->addWidget( label );
	stackLayout->addWidget( sbSize );
	
	stackLayout = new QVBoxLayout( 4 );
	
	pushLayout->addLayout( stackLayout, 30 );
	
	label = new QLabel( cmbCharset, i18n("&Character set"), this );
	label->adjustSize();
	label->setMinimumSize( label->size() );
	
//.........这里部分代码省略.........
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:101,代码来源:fontchooser.cpp


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