本文整理汇总了C++中QScrollView::horizontalScrollBar方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollView::horizontalScrollBar方法的具体用法?C++ QScrollView::horizontalScrollBar怎么用?C++ QScrollView::horizontalScrollBar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollView
的用法示例。
在下文中一共展示了QScrollView::horizontalScrollBar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KDialogBase
Kleo::KeyApprovalDialog::KeyApprovalDialog( const std::vector<Item> & recipients,
const std::vector<GpgME::Key> & sender,
QWidget * parent, const char * name,
bool modal )
: KDialogBase( parent, name, modal, i18n("Encryption Key Approval"), Ok|Cancel, Ok ),
d( 0 )
{
assert( !recipients.empty() );
d = new Private();
QFrame *page = makeMainWidget();
QVBoxLayout * vlay = new QVBoxLayout( page, 0, spacingHint() );
vlay->addWidget( new QLabel( i18n("The following keys will be used for encryption:"), page ) );
QScrollView * sv = new QScrollView( page );
sv->setResizePolicy( QScrollView::AutoOneFit );
vlay->addWidget( sv );
QWidget * view = new QWidget( sv->viewport() );
QGridLayout * glay = new QGridLayout( view, 3, 2, marginHint(), spacingHint() );
glay->setColStretch( 1, 1 );
sv->addChild( view );
int row = -1;
if ( !sender.empty() ) {
++row;
glay->addWidget( new QLabel( i18n("Your keys:"), view ), row, 0 );
d->selfRequester = new EncryptionKeyRequester( true, EncryptionKeyRequester::AllProtocols, view );
d->selfRequester->setKeys( sender );
glay->addWidget( d->selfRequester, row, 1 );
++row;
glay->addMultiCellWidget( new KSeparator( Horizontal, view ), row, row, 0, 1 );
}
const QStringList prefs = preferencesStrings();
for ( std::vector<Item>::const_iterator it = recipients.begin() ; it != recipients.end() ; ++it ) {
++row;
glay->addWidget( new QLabel( i18n("Recipient:"), view ), row, 0 );
glay->addWidget( new QLabel( it->address, view ), row, 1 );
d->addresses.push_back( it->address );
++row;
glay->addWidget( new QLabel( i18n("Encryption keys:"), view ), row, 0 );
KeyRequester * req = new EncryptionKeyRequester( true, EncryptionKeyRequester::AllProtocols, view );
req->setKeys( it->keys );
glay->addWidget( req, row, 1 );
d->requesters.push_back( req );
++row;
glay->addWidget( new QLabel( i18n("Encryption preference:"), view ), row, 0 );
QComboBox * cb = new QComboBox( false, view );
cb->insertStringList( prefs );
glay->addWidget( cb, row, 1 );
cb->setCurrentItem( pref2cb( it->pref ) );
connect( cb, SIGNAL(activated(int)), SLOT(slotPrefsChanged()) );
d->preferences.push_back( cb );
}
// calculate the optimal width for the dialog
const int dialogWidth = marginHint()
+ sv->frameWidth()
+ view->sizeHint().width()
+ sv->verticalScrollBar()->sizeHint().width()
+ sv->frameWidth()
+ marginHint()
+ 2;
// calculate the optimal height for the dialog
const int dialogHeight = marginHint()
+ fontMetrics().height()
+ spacingHint()
+ sv->frameWidth()
+ view->sizeHint().height()
+ sv->horizontalScrollBar()->sizeHint().height()
+ sv->frameWidth()
+ spacingHint()
+ actionButton( KDialogBase::Cancel )->sizeHint().height()
+ marginHint()
+ 2;
// don't make the dialog too large
const QRect desk = KGlobalSettings::desktopGeometry( this );
setInitialSize( QSize( kMin( dialogWidth, 3 * desk.width() / 4 ),
kMin( dialogHeight, 7 * desk.height() / 8 ) ) );
}