本文整理汇总了C++中KHBox::setFixedWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ KHBox::setFixedWidth方法的具体用法?C++ KHBox::setFixedWidth怎么用?C++ KHBox::setFixedWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KHBox
的用法示例。
在下文中一共展示了KHBox::setFixedWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillMenu
void TokenWithLayout::fillMenu( QMenu * menu )
{
DEBUG_BLOCK
KAction *boldAction = new KAction( KIcon( "format-text-bold"), i18n( "Bold" ), menu );
boldAction->setObjectName( ActionBoldName );
boldAction->setCheckable( true );
boldAction->setChecked( m_bold );
KAction *italicAction = new KAction( KIcon( "format-text-italic"), i18n( "Italic" ), menu );
italicAction->setObjectName( ActionItalicName );
italicAction->setCheckable( true );
italicAction->setChecked( m_italic );
KAction *alignLeftAction = new KAction( KIcon( "format-justify-left"), i18n( "Left" ), menu );
KAction *alignCenterAction = new KAction( KIcon( "format-justify-center"), i18n( "Center" ), menu );
KAction *alignRightAction = new KAction( KIcon( "format-justify-right"), i18n( "Right" ), menu );
alignLeftAction->setObjectName( ActionAlignLeftName );
alignLeftAction->setCheckable( true );
alignCenterAction->setObjectName( ActionAlignCenterName );
alignCenterAction->setCheckable( true );
alignRightAction->setObjectName( ActionAlignRightName );
alignRightAction->setCheckable( true );
if ( m_alignment & Qt::AlignLeft )
alignLeftAction->setChecked( true );
else if ( m_alignment & Qt::AlignHCenter )
alignCenterAction->setChecked( true );
else if ( m_alignment & Qt::AlignRight )
alignRightAction->setChecked( true );
QActionGroup *alignmentGroup = new QActionGroup( menu );
alignmentGroup->addAction( alignLeftAction );
alignmentGroup->addAction( alignCenterAction );
alignmentGroup->addAction( alignRightAction );
menu->addAction( boldAction );
menu->addAction( italicAction );
menu->addSeparator()->setText( i18n( "Alignment" ) );
menu->addAction( alignLeftAction );
menu->addAction( alignCenterAction );
menu->addAction( alignRightAction );
menu->addSeparator()->setText( i18n( "Width" ) );
menu->adjustSize();
int orgHeight = menu->height();
KHBox * sliderBox = new KHBox( menu );
sliderBox->setFixedWidth( menu->width() - 4 );
sliderBox->move( sliderBox->pos().x() + 2, orgHeight );
QSlider * slider = new QSlider( Qt::Horizontal, sliderBox );
slider->setMaximum( 100 );
slider->setMinimum( 0 );
// this should really not be done here as it makes upward assumptions
// it was however done in setWidth with similar upward assumptions as well
// solution: the popup stuff -iff- should be done in the dialog or the editWidget
if ( parentWidget() )
{
if ( TokenDropTarget *editWidget = qobject_cast<TokenDropTarget*>( parentWidget() ) )
{
qreal spareWidth = 100.0;
int row = editWidget->row( this );
if ( row > -1 )
{
QList<Token*> tokens = editWidget->drags( row );
foreach (Token *t, tokens)
{
if (t == this)
continue;
if ( TokenWithLayout *twl = qobject_cast<TokenWithLayout*>( t ) )
spareWidth -= twl->width() * 100.0;
}
}
int max = qMax( spareWidth, 0.0 );
debug() << "slider max value: " << max;
if ( max >= m_width * 100.0 )
slider->setMaximum( qMax( spareWidth, 0.0 ) );
else
slider->setMaximum( m_width * 100.0 );
}