本文整理汇总了C++中QScrollArea::widget方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollArea::widget方法的具体用法?C++ QScrollArea::widget怎么用?C++ QScrollArea::widget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollArea
的用法示例。
在下文中一共展示了QScrollArea::widget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotAdjustScrollWidgetSize
void ShareUserGroupWidget::slotAdjustScrollWidgetSize()
{
QScrollArea *scrollArea = _ui->scrollArea;
if (scrollArea->findChildren<ShareWidget*>().count() <= 3) {
auto minimumSize = scrollArea->widget()->sizeHint();
auto spacing = scrollArea->widget()->layout()->spacing();
minimumSize.rwidth() += spacing;
minimumSize.rheight() += spacing;
scrollArea->setMinimumSize(minimumSize);
}
}
示例2: resizeEvent
void SettingsBottomView::resizeEvent(QResizeEvent* event) {
int pages = stack->count();
for (int p = 0; p < pages; ++p) {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(stack->widget(p));
QWidget* page = scrollArea->widget();
page->setFixedWidth(scrollArea->width());
}
}
示例3: addWidget
void ScrollAreaWidgetContainer::addWidget(QWidget *widget)
{
QScrollArea *scrollArea = extendedScrollArea();
if (scrollArea->widget()) {
qmlInfo(scrollArea) << "Can not add multiple Widgets to ScrollArea";
} else {
scrollArea->setWidget(widget);
}
}
示例4: GetImageWidget
ImageWidget* MainWindow::GetImageWidget(int index) const
{
QWidget* widget = ui->imagetab->widget(index);
if (widget) {
QScrollArea* area = qobject_cast<QScrollArea*>(widget);
return qobject_cast<ImageWidget*>(area->widget());
}
return nullptr;
}
示例5: reallyEnsureCursorVisible
void ExpandingTextEdit::reallyEnsureCursorVisible()
{
QObject *ancestor = parent();
while (ancestor) {
QScrollArea *scrollArea = qobject_cast<QScrollArea*>(ancestor);
if (scrollArea &&
(scrollArea->verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff &&
scrollArea->horizontalScrollBarPolicy() != Qt::ScrollBarAlwaysOff)) {
const QRect &r = cursorRect();
const QPoint &c = mapTo(scrollArea->widget(), r.center());
scrollArea->ensureVisible(c.x(), c.y());
break;
}
ancestor = ancestor->parent();
}
}
示例6: onSaveButton
void MainWindow::onSaveButton()
{
DataItem items;
if (avatarWidget) {
DataItem avatarItem = avatarWidget->item();
items.addSubitem(avatarItem);
}
for (int i = 0; i < ui.detailsStackedWidget->count(); ++i) {
QWidget *widget = ui.detailsStackedWidget->widget(i);
Q_ASSERT(qobject_cast<QScrollArea*>(widget));
QScrollArea *scrollArea = static_cast<QScrollArea*>(widget);
AbstractDataForm *dataFrom = qobject_cast<AbstractDataForm*>(scrollArea->widget());
if (!dataFrom)
continue;
if (dataFrom->objectName() == "General") {
foreach (const DataItem &item, dataFrom->item().subitems())
items.addSubitem(item);
} else {
示例7: commit
void SettingsBottomView::commit() {
int pages = stack->count();
for (int p = 0; p < pages; ++p) {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(stack->widget(p));
QWidget* page = scrollArea->widget();
QGridLayout* layout = qobject_cast<QGridLayout*>(page->layout());
QModelIndex pageIndex = model()->index(p, 0);
for (int i = 0; i < layout->rowCount(); ++i) {
QLayoutItem* item = layout->itemAtPosition(i, 1);
if (!item) continue; // Prevent segfault for empty layout
QWidget* editor = item->widget();
QModelIndex dataIndex = model()->index(i, 0, pageIndex);
itemDelegate()->setModelData(editor, model(), dataIndex);
}
}
}
示例8: dataChanged
void SettingsBottomView::dataChanged(
const QModelIndex& topLeft,
const QModelIndex& bottomRight) {
QModelIndex parent = topLeft.parent();
// If modifying data for a group, don't do anything
if (!parent.isValid()) return;
// Don't allow modifying more than one data element
if (topLeft != bottomRight) {
qDebug() << "Warning: the settings view does not allow batch modification";
return;
}
QScrollArea* scrollArea =
qobject_cast<QScrollArea*>(stack->widget(parent.row()));
QWidget* page = scrollArea->widget();
QGridLayout* layout = qobject_cast<QGridLayout*>(page->layout());
QWidget* widget;
QLayoutItem* item;
// Setting description
item = layout->itemAtPosition(topLeft.row(), 0);
QString description = getSettingDescription(topLeft);
if (!item) {
widget = new QLabel(description, NULL);
layout->addWidget(widget, topLeft.row(), 0);
} else {
widget = item->widget();
qobject_cast<QLabel*>(widget)->setText(description);
}
// Setting value
item = layout->itemAtPosition(topLeft.row(), 1);
if (!item) {
widget = createEditorForIndex(topLeft);
layout->addWidget(widget, topLeft.row(), 1);
widget->show();
} else {
widget = item->widget();
}
QAbstractItemDelegate* delegate = itemDelegate(topLeft);
delegate->setEditorData(widget, topLeft);
}
示例9: editorValuesChanged
bool SettingsBottomView::editorValuesChanged() {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(stack->currentWidget());
QWidget* page = scrollArea->widget();
QGridLayout* layout = qobject_cast<QGridLayout*>(page->layout());
QModelIndex pageIndex = model()->index(stack->currentIndex(), 0);
for (int i = 0; i < layout->rowCount(); ++i) {
QLayoutItem* item = layout->itemAtPosition(i, 1);
if (!item) continue; // Prevent segfault for empty layout
QWidget* editor = item->widget();
QByteArray propertyName = editor->metaObject()->userProperty().name();
QVariant editorData = editor->property(propertyName);
QModelIndex dataIndex = model()->index(i, 0, pageIndex);
QVariant modelData = model()->data(dataIndex, Qt::EditRole);
if (!variantsEqual(editorData, modelData)) return true;
}
return false;
}
示例10: setModelData
//-----------------------------------------------------------------------------
// Function: RemapConditionDelegate::setModelData()
//-----------------------------------------------------------------------------
void RemapConditionDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index)
const
{
if (index.column() == RemapConditionColumns::NAME_COLUMN)
{
ReferenceSelector* referenceSelector = qobject_cast<ReferenceSelector*>(editor);
QString text = referenceSelector->currentText();
model->setData(index, text, Qt::EditRole);
}
else if (index.column() == RemapConditionColumns::VALUE_COLUMN && valueIsArray(index))
{
QScrollArea* scrollWidget = qobject_cast<QScrollArea*>(editor);
ArrayView* arrayTable = qobject_cast<ArrayView*>(scrollWidget->widget());
ParameterArrayModel* arrayModel = qobject_cast<ParameterArrayModel*>(arrayTable->model());
QString arrayValue = arrayModel->getArrayData();
model->setData(index, arrayValue, Qt::EditRole);
}
else
{
ExpressionDelegate::setModelData(editor, model, index);
}
}
示例11: checkForWizard
void ViewProviderFemConstraint::checkForWizard()
{
wizardWidget= NULL;
wizardSubLayout = NULL;
Gui::MainWindow* mw = Gui::getMainWindow();
if (mw == NULL) return;
QDockWidget* dw = mw->findChild<QDockWidget*>(QObject::tr("Combo View"));
if (dw == NULL) return;
QWidget* cw = dw->findChild<QWidget*>(QObject::tr("Combo View"));
if (cw == NULL) return;
QTabWidget* tw = cw->findChild<QTabWidget*>(QObject::tr("combiTab"));
if (tw == NULL) return;
QStackedWidget* sw = tw->findChild<QStackedWidget*>(QObject::tr("qt_tabwidget_stackedwidget"));
if (sw == NULL) return;
QScrollArea* sa = sw->findChild<QScrollArea*>();
if (sa== NULL) return;
QWidget* wd = sa->widget(); // This is the reason why we cannot use findChildByName() right away!!!
if (wd == NULL) return;
QObject* wiz = findChildByName(wd, QObject::tr("ShaftWizard")); // FIXME: Actually, we don't want to translate this...
if (wiz != NULL) {
wizardWidget = static_cast<QVBoxLayout*>(wiz);
wizardSubLayout = wiz->findChild<QVBoxLayout*>(QObject::tr("ShaftWizardLayout"));
}
}
示例12: CryptoConfigComponentGUI
void Kleo::CryptoConfigModule::init( Layout layout ) {
Kleo::CryptoConfig * const config = mConfig;
const KPageView::FaceType type=determineJanusFace( config, layout );
setFaceType(type);
QVBoxLayout * vlay = 0;
QWidget * vbox = 0;
if ( type == Plain ) {
vbox = new QWidget(this);
vlay = new QVBoxLayout( vbox );
vlay->setSpacing( KDialog::spacingHint() );
vlay->setMargin( 0 );
addPage( vbox, i18n("GpgConf Error") );
}
const QStringList components = config->componentList();
for ( QStringList::const_iterator it = components.begin(); it != components.end(); ++it ) {
//kDebug(5150) <<"Component" << (*it).toLocal8Bit() <<":";
Kleo::CryptoConfigComponent* comp = config->component( *it );
Q_ASSERT( comp );
if ( comp->groupList().empty() )
continue;
if ( type != Plain ) {
vbox = new QWidget(this);
vlay = new QVBoxLayout( vbox );
vlay->setSpacing( KDialog::spacingHint() );
vlay->setMargin( 0 );
KPageWidgetItem *pageItem = new KPageWidgetItem( vbox, comp->description() );
if ( type != Tabbed )
pageItem->setIcon( loadIcon( comp->iconName() ) );
addPage(pageItem);
}
QScrollArea* scrollArea = type == Tabbed ? new QScrollArea( this ) : new ScrollArea( this );
scrollArea->setWidgetResizable( true );
vlay->addWidget( scrollArea );
CryptoConfigComponentGUI* compGUI =
new CryptoConfigComponentGUI( this, comp, scrollArea );
compGUI->setObjectName( *it );
scrollArea->setWidget( compGUI );
scrollArea->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
// KJanusWidget doesn't seem to have iterators, so we store a copy...
mComponentGUIs.append( compGUI );
// Set a nice startup size
const int deskHeight = QApplication::desktop()->height();
int dialogHeight;
if (deskHeight > 1000) // very big desktop ?
dialogHeight = 800;
else if (deskHeight > 650) // big desktop ?
dialogHeight = 500;
else // small (800x600, 640x480) desktop
dialogHeight = 400;
assert( scrollArea->widget() );
if ( type != Tabbed )
scrollArea->setMinimumHeight( qMin( compGUI->sizeHint().height(), dialogHeight ) );
}
if ( mComponentGUIs.empty() ) {
const QString msg = i18n("The gpgconf tool used to provide the information "
"for this dialog does not seem to be installed "
"properly. It did not return any components. "
"Try running \"%1\" on the command line for more "
"information.",
components.empty() ? "gpgconf --list-components" : "gpgconf --list-options gpg" );
QLabel * label = new QLabel( msg, vbox );
label->setWordWrap( true);
label->setMinimumHeight( fontMetrics().lineSpacing() * 5 );
vlay->addWidget( label );
}
}
示例13: PFSViewException
PFSViewMainWin::PFSViewMainWin( float window_min, float window_max ):
QMainWindow( 0 )
{
currentFrame = frameList.end();
QScrollArea *pfsViewArea = new PFSViewWidgetArea( this );
pfsView = (PFSViewWidget*)pfsViewArea->widget();
setCentralWidget( pfsViewArea );
setWindowIcon( QIcon( ":icons/appicon.png" ) );
QAction *nextFrameAct = new QAction( tr( "&Next frame" ), this );
nextFrameAct->setStatusTip( tr( "Load next frame" ) );
nextFrameAct->setShortcut( Qt::Key_PageDown );
connect( nextFrameAct, SIGNAL(triggered()), this, SLOT(gotoNextFrame()) );
QAction *previousFrameAct = new QAction( tr( "&Previous frame" ), this );
previousFrameAct->setStatusTip( tr( "Load previous frame" ) );
previousFrameAct->setShortcut( Qt::Key_PageUp );
connect( previousFrameAct, SIGNAL(triggered()), this, SLOT(gotoPreviousFrame()) );
QToolBar *toolBar = addToolBar( tr( "Navigation" ) );
// toolBar->setHorizontalStretchable( true );
QToolButton *previousFrameBt = new QToolButton( toolBar );
previousFrameBt->setArrowType( Qt::LeftArrow );
previousFrameBt->setMinimumWidth( 15 );
connect( previousFrameBt, SIGNAL(clicked()), this, SLOT(gotoPreviousFrame()) );
previousFrameBt->setToolTip( "Goto previous frame" );
toolBar->addWidget( previousFrameBt );
QToolButton *nextFrameBt = new QToolButton( toolBar );
nextFrameBt->setArrowType( Qt::RightArrow );
nextFrameBt->setMinimumWidth( 15 );
connect( nextFrameBt, SIGNAL(clicked()), this, SLOT(gotoNextFrame()) );
nextFrameBt->setToolTip( "Goto next frame" );
toolBar->addWidget( nextFrameBt );
QLabel *channelSelLabel = new QLabel( "&Channel", toolBar );
channelSelection = new QComboBox( toolBar );
channelSelLabel->setBuddy( channelSelection );
connect( channelSelection, SIGNAL( activated( int ) ),
this, SLOT( setChannelSelection(int) ) );
toolBar->addWidget( channelSelLabel );
toolBar->addWidget( channelSelection );
toolBar->addSeparator();
QLabel *mappingMethodLabel = new QLabel( "&Mapping", toolBar );
mappingMethodLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); // |
// Qt::TextExpandTabs | Qt::TextShowMnemonic );
mappingMethodCB = new QComboBox( toolBar );
mappingMethodLabel->setBuddy( mappingMethodCB );
mappingMethodCB->addItem( "Linear" );
mappingMethodCB->addItem( "Gamma 1.4" );
mappingMethodCB->addItem( "Gamma 1.8" );
mappingMethodCB->addItem( "Gamma 2.2" );
mappingMethodCB->addItem( "Gamma 2.6" );
mappingMethodCB->addItem( "Logarithmic" );
mappingMethodCB->setCurrentIndex( 3 );
connect( mappingMethodCB, SIGNAL( activated( int ) ),
this, SLOT( setLumMappingMethod(int) ) );
toolBar->addWidget( mappingMethodLabel );
toolBar->addWidget( mappingMethodCB );
// addToolBar( Qt::BottomToolBarArea, toolBar );
QToolBar *toolBarLR = addToolBar( tr( "Histogram" ) );
lumRange = new LuminanceRangeWidget( toolBarLR );
connect( lumRange, SIGNAL( updateRangeWindow() ), this,
SLOT( updateRangeWindow() ) );
toolBarLR->addWidget( lumRange );
// addToolBar( toolBar );
pointerPosAndVal = new QLabel( statusBar() );
statusBar()->addWidget( pointerPosAndVal );
// QFont fixedFont = QFont::defaultFont();
// fixedFont.setFixedPitch( true );
// pointerPosAndVal->setFont( fixedFont );
zoomValue = new QLabel( statusBar() );
statusBar()->addWidget( zoomValue );
exposureValue = new QLabel( statusBar() );
statusBar()->addWidget( exposureValue );
connect( pfsView, SIGNAL(updatePointerValue()),
this, SLOT(updatePointerValue()) );
QMenu *frameMenu = menuBar()->addMenu( tr( "&Frame" ) );
frameMenu->addAction( nextFrameAct );
frameMenu->addAction( previousFrameAct );
frameMenu->addSeparator();
frameMenu->addAction( "&Save image...", this, SLOT(saveImage()), QKeySequence::Save );
frameMenu->addAction( "&Copy image to clipboard", this, SLOT(copyImage()), QKeySequence::Copy );
frameMenu->addSeparator();
frameMenu->addAction( "&Quit", qApp, SLOT(quit()), Qt::Key_Q ); //QKeySequence::Quit
//.........这里部分代码省略.........
示例14: setup
// Setup widget
void MyWidget::setup(int layoutMargin, QString borderColor, QString backgroundColor) {
// Some styling
visibleArea = QSize(600,400);
this->borderColor = borderColor;
this->backgroundColor = (backgroundColor == "" ? "rgba(0,0,0,200)" : backgroundColor);
borderLeftRight = -1;
borderTopDown = -1;
fullscreen = false;
// The different QRects
rectShown = QRect();
rectHidden = QRect(0,-10,10,10);
rectAni = QRect();
// The current geometry and position
isShown = false;
this->setGeometry(rectHidden);
// Fading
backOpacityShow = 0.5;
backOpacityCur = 0;
centerOpacityCur = 0;
fade = new QTimeLine;
fadeIN = true;
fadeEffectCenter = new QGraphicsOpacityEffect;
connect(fade, SIGNAL(valueChanged(qreal)), this, SLOT(fadeStep()));
connect(fade, SIGNAL(finished()), this, SLOT(aniFinished()));
// The current widget look
this->setStyleSheet(QString("background: rgba(0,0,0,%1);").arg(255*backOpacityShow));
// the central widget containing all the information
center = new QWidget(this);
center->setGraphicsEffect(fadeEffectCenter);
center->setObjectName("center");
// For some reason, if the border is not defined right here at the beginning, it wont be visible...
if(borderColor == "")
center->setStyleSheet(QString("#center { background: %1; border-radius: 10px; font-size: 12pt; }").arg(this->backgroundColor));
else
center->setStyleSheet(QString("#center {background: %1; border-radius: 15px; font-size: 12pt; border: 2px solid %2; }").arg(this->backgroundColor).arg(borderColor));
// Create and set the scrollarea with main layout
QVBoxLayout *central = new QVBoxLayout;
central->setMargin(layoutMargin);
QScrollArea *scroll = new QScrollArea(this);
scroll->setObjectName("scrollWidget");
scroll->setStyleSheet("QWidget#scrollWidget { background: transparent; padding-bottom: 3px; border-radius: 0px; }");
QWidget *scrollWidget = new QWidget(scroll->widget());
scrollWidget->setStyleSheet("background: transparent;");
scroll->setWidgetResizable(true);
scroll->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
scrollWidget->setLayout(central);
scroll->setWidget(scrollWidget);
mainlayout = new QVBoxLayout;
if(layoutMargin == 0) mainlayout->setMargin(0);
center->setLayout(mainlayout);
mainlayout->addWidget(scroll);
// This widget gets the main layout set to
centralWidget = new QWidget;
central->addWidget(centralWidget);
// And set the custom scrollbar
scrollbar = new CustomScrollbar;
scroll->setVerticalScrollBar(scrollbar);
// And in case the monitor resolution is so small, that the horizontal scrollbar is visible:
CustomScrollbar *scrollbarHor = new CustomScrollbar;
scroll->setHorizontalScrollBar(scrollbarHor);
}
示例15: makeSelectedTileset
void TilesetItemBox::makeSelectedTileset(int tabIndex)
{
if(lockTilesetBox)
return;
QGraphicsScene *scene = NULL;
LevelEdit *lvlEdit = mw()->activeLvlEditWin();
WorldEdit *wldEdit = mw()->activeWldEditWin();
if((lvlEdit) && (lvlEdit->sceneCreated))
scene = lvlEdit->scene;
else if((wldEdit) && (wldEdit->sceneCreated))
scene = wldEdit->scene;
QTabWidget *cat = ui->TileSetsCategories;
if(!(cat->tabText(tabIndex) == "Custom"))
{
QWidget *current = cat->widget(tabIndex);
if(!current)
return;
QString category = cat->tabText(tabIndex);
#ifdef _DEBUG_
DevConsole::log(QString("Category %1").arg(cat->tabText(cat->currentIndex())), "Debug");
#endif
QScrollArea *currentFrame = getFrameTilesetOfTab(current);
QComboBox *currentCombo = getGroupComboboxOfTab(current);
if(!currentFrame || !currentCombo)
return;
QWidget *scrollWid = currentFrame->widget();
if(!scrollWid)
return;
qDeleteAll(scrollWid->findChildren<QGroupBox *>());
if(scrollWid->layout() == 0)
scrollWid->setLayout(new FlowLayout());
currentFrame->setWidgetResizable(true);
#ifdef _DEBUG_
DevConsole::log(QString("size %1 %2")
.arg(scrollWid->layout()->geometry().width())
.arg(scrollWid->layout()->geometry().height())
, "Debug");
#endif
QString currentGroup = currentCombo->currentText();
for(int i = 0; i < mw()->configs.main_tilesets_grp.size(); i++)
{
if((mw()->configs.main_tilesets_grp[i].groupCat == category)
&& (mw()->configs.main_tilesets_grp[i].groupName == currentGroup)) //category
{
#ifdef _DEBUG_
DevConsole::log(QString("Group %1").arg(configs.main_tilesets_grp[i].groupName), "Debug");
DevConsole::log(QString("Tilesets %1").arg(configs.main_tilesets_grp[i].tilesets.size()), "Debug");
#endif
QStringList l = mw()->configs.main_tilesets_grp[i].tilesets;
foreach(QString s, l)
{
for(int j = 0; j < mw()->configs.main_tilesets.size(); j++)
{
if(s == mw()->configs.main_tilesets[j].fileName)
{
SimpleTileset &s = mw()->configs.main_tilesets[j];
QGroupBox *tilesetNameWrapper = new QGroupBox(s.tileSetName, scrollWid);
((FlowLayout *)scrollWid->layout())->addWidget(tilesetNameWrapper);
QGridLayout *l = new QGridLayout(tilesetNameWrapper);
l->setContentsMargins(4, 4, 4, 4);
l->setSpacing(2);
for(int k = 0; k < s.items.size(); k++)
{
SimpleTilesetItem &item = s.items[k];
TilesetItemButton *tbutton = new TilesetItemButton(&mw()->configs, scene, tilesetNameWrapper);
tbutton->applySize(32, 32);
tbutton->applyItem(s.type, item.id);
l->addWidget(tbutton, item.row, item.col);
connect(tbutton, SIGNAL(clicked(int, ulong)), mw(), SLOT(SwitchPlacingItem(int, ulong)));
}
break;
}
}
}
break;
}
}