本文整理汇总了C++中QScrollArea::setContentsMargins方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollArea::setContentsMargins方法的具体用法?C++ QScrollArea::setContentsMargins怎么用?C++ QScrollArea::setContentsMargins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollArea
的用法示例。
在下文中一共展示了QScrollArea::setContentsMargins方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
NotifyManager::NotifyManager(QWidget *parent) :
QWidget(parent),
m_dbus(new Notification("com.deepin.dde.Notification", "/com/deepin/dde/Notification", QDBusConnection::sessionBus(), this))
{
QWidget *widget = new QWidget;
m_connectLayout = new QVBoxLayout(widget);
m_connectLayout->setMargin(0);
m_connectLayout->setSpacing(1);
m_connectLayout->addStretch();
QScrollArea *scrollarea = new QScrollArea;
scrollarea->setWidget(widget);
scrollarea->setObjectName("scrollarea");
scrollarea->setWidgetResizable(true);
scrollarea->setFocusPolicy(Qt::NoFocus);
scrollarea->setFrameStyle(QFrame::NoFrame);
scrollarea->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
scrollarea->setContentsMargins(0, 0, 0, 0);
scrollarea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollarea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollarea->setStyleSheet("background-color:transparent;");
QScrollBar *bar = scrollarea->verticalScrollBar();
connect(bar, &QScrollBar::valueChanged, this, [=](int value){
if (m_checkIndex && value == bar->maximum())
onLoadAgain();
});
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
m_clearButton = new DImageButton;
m_clearButton->setText(tr("Clear all"));
m_clearButton->setStyleSheet("padding: 4px 0;");
mainLayout->addWidget(m_clearButton, 0, Qt::AlignHCenter);
mainLayout->addWidget(scrollarea);
setLayout(mainLayout);
m_clearButton->setVisible(false);
connect(m_clearButton, &DImageButton::clicked, this, &NotifyManager::onCloseAllItem);
connect(m_dbus, &Notification::RecordAdded, this, &NotifyManager::onNotifyAdded);
m_dbus->setSync(false);
QDBusPendingReply<QString> notify = m_dbus->GetAllRecords();
QDBusPendingCallWatcher *notifyWatcher = new QDBusPendingCallWatcher(notify, this);
connect(notifyWatcher, &QDBusPendingCallWatcher::finished, this, &NotifyManager::onNotifyGetAllFinished);
}
示例2: QDialog
VoreenSettingsDialog::VoreenSettingsDialog(QWidget* parent)
: QDialog(parent, Qt::Tool | Qt::Window)
{
setWindowTitle(tr("Voreen Settings Editor"));
QVBoxLayout* mainLayout = new QVBoxLayout();
setLayout(mainLayout);
// scroll area
QScrollArea* scrollArea = new QScrollArea(this);
scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setContentsMargins(0, 0, 0, 0);
mainLayout->addWidget(scrollArea);
// container widget for PropertyOwnerWidgets
QWidget* containerWidget = new QWidget();
scrollArea->setWidget(containerWidget);
QVBoxLayout* widgetLayout = new QVBoxLayout();
containerWidget->setLayout(widgetLayout);
// application widget
PropertyOwnerWidget* appPow = new PropertyOwnerWidget(this, VoreenApplication::app(), "Application Settings", true, false);
widgetLayout->addWidget(appPow);
// module widgets
VoreenApplication* va = VoreenApplication::app();
const std::vector<VoreenModule*>& modules = va->getModules();
for(size_t i=0; i<modules.size(); i++) {
if(!modules[i]->getProperties().empty()) {
widgetLayout->addSpacerItem(new QSpacerItem(1, 8));
PropertyOwnerWidget* modulePow = new PropertyOwnerWidget(this, modules[i], "Module: " + modules[i]->getID(), true, false);
widgetLayout->addWidget(modulePow);
}
}
widgetLayout->addStretch();
// button row
mainLayout->addSpacerItem(new QSpacerItem(1, 4));
QHBoxLayout* buttonLayout = new QHBoxLayout();
resetButton_ = new QPushButton("Reset");
buttonLayout->addWidget(resetButton_);
buttonLayout->addStretch();
closeButton_ = new QPushButton("Close");
buttonLayout->addWidget(closeButton_);
mainLayout->addLayout(buttonLayout);
connect(resetButton_, SIGNAL(clicked()), this, SLOT(resetSettings()));
connect(closeButton_, SIGNAL(clicked()), this, SIGNAL(closeSettings()));
}
示例3: ShadowWidget
PlayListWidget::PlayListWidget(QWidget *parent)
: ShadowWidget(parent)
, col(1)
, currentIndex(0)
, pImpl(new PlayListWidget_Impl())
{
setAttribute(Qt::WA_QuitOnClose, false);
setWindowModality(Qt::ApplicationModal);
QPalette text_palette = palette();
text_palette.setColor(QPalette::Window, QColor(225, 225, 225));
text_palette.setColor(QPalette::Background, QColor(255, 255, 255, 120));
setPalette(text_palette);
QHBoxLayout *up_title_layout = new QHBoxLayout;
set_no_margin(up_title_layout);
connect(pImpl->btn_close, SIGNAL(clicked()), this, SLOT(hide()));
up_title_layout->addWidget(pImpl->btn_close, 0, Qt::AlignTop);
up_title_layout->addStretch();
QVBoxLayout *main_layout = new QVBoxLayout(this);
QScrollArea *view = new QScrollArea;
view->setWidgetResizable(true);
view->setContentsMargins(0, 0, 0, 0);
QWidget *viewWidgetContents = new QWidget(view);
QVBoxLayout *tmp_layout = new QVBoxLayout(viewWidgetContents);
tmp_layout->addLayout(pImpl->scroll_layout);
tmp_layout->addStretch();
view->setWidget(viewWidgetContents);
main_layout->addLayout(up_title_layout);
main_layout->addWidget(view);
main_layout->setSpacing(0);
viewWidgetContents->setPalette(text_palette);
main_layout->setContentsMargins(5, 5, 5, 5);
viewWidgetContents->setFixedWidth(380);
setFixedSize(400, 300);
connect(pImpl->play_next_key, SIGNAL(triggered()), SLOT(on_playNext_clicked()));
connect(pImpl->play_prev_key, SIGNAL(triggered()), SLOT(on_playPrev_clicked()));
}
示例4: QWidget
KeyBinder::KeyBinder(QWidget * parent, const QString & helpText, const QString & defaultText, const QString & resetButtonText) : QWidget(parent)
{
this->defaultText = defaultText;
enableSignal = false;
// Two-column tab layout
QHBoxLayout * pageKeysLayout = new QHBoxLayout(this);
pageKeysLayout->setSpacing(0);
pageKeysLayout->setContentsMargins(0, 0, 0, 0);
// Table for category list
QVBoxLayout * catListContainer = new QVBoxLayout();
catListContainer->setContentsMargins(10, 10, 10, 10);
catList = new QListWidget();
catList->setFixedWidth(180);
catList->setStyleSheet("QListWidget::item { font-size: 14px; } QListWidget:hover { border-color: #F6CB1C; } QListWidget::item:selected { background: #150A61; color: yellow; }");
catList->setFocusPolicy(Qt::NoFocus);
connect(catList, SIGNAL(currentRowChanged(int)), this, SLOT(changeBindingsPage(int)));
catListContainer->addWidget(catList);
pageKeysLayout->addLayout(catListContainer);
// Reset all binds button
if (!resetButtonText.isEmpty())
{
QPushButton * btnResetAll = new QPushButton(resetButtonText);
catListContainer->addWidget(btnResetAll);
btnResetAll->setFixedHeight(40);
catListContainer->setStretch(1, 0);
catListContainer->setSpacing(10);
connect(btnResetAll, SIGNAL(clicked()), this, SIGNAL(resetAllBinds()));
}
// Container for pages of key bindings
QWidget * bindingsPagesContainer = new QWidget();
QVBoxLayout * rightLayout = new QVBoxLayout(bindingsPagesContainer);
// Scroll area for key bindings
QScrollArea * scrollArea = new QScrollArea();
scrollArea->setContentsMargins(0, 0, 0, 0);
scrollArea->setWidget(bindingsPagesContainer);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
scrollArea->setWidgetResizable(true);
scrollArea->setFrameShape(QFrame::NoFrame);
scrollArea->setStyleSheet("background: #130F2A;");
// Add key binding pages to bindings tab
pageKeysLayout->addWidget(scrollArea);
pageKeysLayout->setStretch(1, 1);
// Custom help text
QLabel * helpLabel = new QLabel();
helpLabel->setText(helpText);
helpLabel->setStyleSheet("color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-radius: 10px; padding: auto 20px;");
helpLabel->setFixedHeight(24);
rightLayout->addWidget(helpLabel, 0, Qt::AlignCenter);
// Category list and bind table row heights
const int rowHeight = 20;
QSize catSize, headerSize;
catSize.setHeight(36);
headerSize.setHeight(24);
// Category list header
QListWidgetItem * catListHeader = new QListWidgetItem(tr("Category"));
catListHeader->setSizeHint(headerSize);
catListHeader->setFlags(Qt::NoItemFlags);
catListHeader->setForeground(QBrush(QColor("#130F2A")));
catListHeader->setBackground(QBrush(QColor("#F6CB1C")));
catListHeader->setTextAlignment(Qt::AlignCenter);
catList->addItem(catListHeader);
// Populate
bindingsPages = new QHBoxLayout();
bindingsPages->setContentsMargins(0, 0, 0, 0);
rightLayout->addLayout(bindingsPages);
QWidget * curPage = NULL;
QVBoxLayout * curLayout = NULL;
QTableWidget * curTable = NULL;
bool bFirstPage = true;
selectedBindTable = NULL;
bindComboBoxCellMappings = new QHash<QObject *, QTableWidgetItem *>();
bindCellComboBoxMappings = new QHash<QTableWidgetItem *, QComboBox *>();
for (int i = 0; i < BINDS_NUMBER; i++)
{
if (cbinds[i].category != NULL)
{
// Add stretch at end of previous layout
if (curLayout != NULL) curLayout->insertStretch(-1, 1);
// Category list item
QListWidgetItem * catItem = new QListWidgetItem(HWApplication::translate("binds (categories)", cbinds[i].category));
catItem->setSizeHint(catSize);
catList->addItem(catItem);
// Create new page
curPage = new QWidget();
curLayout = new QVBoxLayout(curPage);
curLayout->setSpacing(2);
bindingsPages->addWidget(curPage);
if (!bFirstPage) curPage->setVisible(false);
//.........这里部分代码省略.........