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


C++ KVBox::setSizePolicy方法代码示例

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


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

示例1: QLabel

RKProgressControlDialog::RKProgressControlDialog (const QString &text, const QString &caption, int mode_flags, bool modal) : KDialog (0) {
	RK_TRACE (MISC);

	setAttribute (Qt::WA_DeleteOnClose, true);
	setModal (modal);
	setCaption (caption);

	KVBox *vbox = new KVBox (this);
	vbox->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
	setMainWidget (vbox);

	QLabel *label = new QLabel (text, vbox);
	label->setWordWrap (true);

	error_indicator = new QLabel (i18n ("<b>There have been errors and / or warnings! See below for a transcript</b>"), vbox);
	QPalette palette = error_indicator->palette ();
	palette.setColor (error_indicator->foregroundRole (), QColor (255, 0, 0));
	error_indicator->setPalette (palette);
	error_indicator->hide ();

	KVBox* output_box = new KVBox ();
	if (mode_flags & (RKProgressControl::IncludeErrorOutput | RKProgressControl::IncludeRegularOutput)) {
		QString ocaption;
		if (mode_flags & RKProgressControl::IncludeRegularOutput) {
			output_button_text = i18n ("Output");
			ocaption = i18n ("Output:");
		} else {
			output_button_text = i18n ("Errors / Warnings");
			ocaption = i18n ("Errors / Warnings:");
		}
		new QLabel (ocaption, output_box);

		output_text = new QTextEdit (output_box);
		output_text->setReadOnly (true);
		output_text->setPlainText (QString ());
		output_text->setUndoRedoEnabled (false);
		output_text->setLineWrapMode (QTextEdit::NoWrap);
		output_text->setMinimumWidth (QFontMetrics (output_text->font ()).averageCharWidth () * RKSettingsModuleR::getDefaultWidth ());
		output_box->setStretchFactor (output_text, 10);
	}
	setDetailsWidget (output_box);
	// it's important to use a queued connection, here. Otherwise, if the details widget gets shown due to error output, scrollDown() would only scroll to the position directly *above* the new output.
	connect (this, SIGNAL(aboutToShowDetails()), this, SLOT(scrollDown()), Qt::QueuedConnection);

	KDialog::ButtonCodes button_codes = KDialog::Cancel;
	if (mode_flags & RKProgressControl::OutputSwitchable) button_codes |= KDialog::Details;
	setButtons (button_codes);
	if (button_codes & KDialog::Details) setButtonText (KDialog::Details, output_button_text);
	if (mode_flags & RKProgressControl::AllowCancel) setButtonText (KDialog::Cancel, i18n ("Cancel"));
	else (setCloseTextToClose ());

	if (mode_flags & RKProgressControl::OutputShownByDefault) setDetailsWidgetVisible (true);

	prevent_close = (mode_flags & RKProgressControl::PreventClose);

	last_output_type = ROutput::Output;
	is_done = false;
}
开发者ID:svn2github,项目名称:rkward-svn-mirror,代码行数:58,代码来源:rkprogresscontrol.cpp

示例2: QToolButton

VolumePopupButton::VolumePopupButton( QWidget * parent, PlayerManager *mgr ) :
    QToolButton( parent ),
    m_prevVolume(0.0),
    m_curVolume(0.0),
    player(mgr)
{
    //create the volume popup
    m_volumeMenu = new QMenu( this );

    KVBox *mainBox = new KVBox( this );

    m_volumeLabel= new QLabel( mainBox );
    m_volumeLabel->setAlignment( Qt::AlignHCenter );

    KHBox *sliderBox = new KHBox( mainBox );
    m_volumeSlider = new VolumeSlider( 100, sliderBox, false );
    m_volumeSlider->setFixedHeight( 170 );
    mainBox->setMargin( 0 );
    mainBox->setSpacing( 0 );
    sliderBox->setSpacing( 0 );
    sliderBox->setMargin( 0 );
    mainBox->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
    sliderBox->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );

    QWidgetAction *sliderActionWidget = new QWidgetAction( this );
    sliderActionWidget->setDefaultWidget( mainBox );

    // volumeChanged is a customSignal, is not emited by setValue()
    connect( m_volumeSlider, SIGNAL(volumeChanged(float)), player, SLOT(setVolume(float)) );

    QToolBar *muteBar = new QToolBar( QString(), mainBox );
    muteBar->setContentsMargins( 0, 0, 0, 0 );
    muteBar->setIconSize( QSize( 16, 16 ) );

    // our popup's mute-toggle  button
    m_muteAction = new QAction( KIcon( "audio-volume-muted" ), QString(), muteBar );
    m_muteAction->setToolTip( i18n( "Mute/Unmute" ) );

    connect( m_muteAction, SIGNAL(triggered(bool)), this, SLOT(slotToggleMute(bool)) );
    connect( player, SIGNAL(mutedChanged(bool)), this, SLOT(slotMuteStateChanged(bool)) );

    m_volumeMenu->addAction( sliderActionWidget );
    muteBar->addAction( m_muteAction );

    /* set icon and label to match create state of AudioOutput, as the
     * desired volume value is not available yet (because the player
     * object is not set up yet.) Someone must call PlayerManager::setVolume()
     * later.
     */
    slotVolumeChanged( 1.0 );

    // let player notify us when volume changes
    connect( player, SIGNAL(volumeChanged(float)), this, SLOT(slotVolumeChanged(float)) );
}
开发者ID:mjs973b,项目名称:jukebox,代码行数:54,代码来源:volumepopupbutton.cpp


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