本文整理汇总了C++中QDockWidget::setContentsMargins方法的典型用法代码示例。如果您正苦于以下问题:C++ QDockWidget::setContentsMargins方法的具体用法?C++ QDockWidget::setContentsMargins怎么用?C++ QDockWidget::setContentsMargins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDockWidget
的用法示例。
在下文中一共展示了QDockWidget::setContentsMargins方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeHint
void tst_QDockWidget::task169808_setFloating()
{
//we try to test if the sizeHint of the dock widget widget is taken into account
class MyWidget : public QWidget
{
public:
QSize sizeHint() const
{
const QRect& deskRect = qApp->desktop()->availableGeometry();
return QSize(qMin(300, deskRect.width() / 2), qMin(300, deskRect.height() / 2));
}
QSize minimumSizeHint() const
{
return QSize(20,20);
}
void paintEvent(QPaintEvent *)
{
QPainter p(this);
p.fillRect(rect(), Qt::red);
}
};
QMainWindow mw;
mw.setCentralWidget(new MyWidget);
QDockWidget *dw = new QDockWidget("my dock");
dw->setWidget(new MyWidget);
mw.addDockWidget(Qt::LeftDockWidgetArea, dw);
dw->setFloating(true);
mw.show();
QVERIFY(QTest::qWaitForWindowExposed(&mw));
QCOMPARE(dw->widget()->size(), dw->widget()->sizeHint());
//and now we try to test if the contents margin is taken into account
dw->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
dw->setFloating(false);
QVERIFY(QTest::qWaitForWindowExposed(&mw));
qApp->processEvents(); //leave time processing events
const QSize oldSize = dw->size();
const int margin = 20;
dw->setContentsMargins(margin, margin, margin, margin);
QVERIFY(QTest::qWaitForWindowExposed(&mw));
qApp->processEvents(); //leave time processing events
//widget size shouldn't have changed
QCOMPARE(dw->widget()->size(), dw->widget()->sizeHint());
//dockwidget should be bigger
QCOMPARE(dw->size(), oldSize + QSize(margin * 2, margin * 2));
}
示例2: QSKIP
void tst_QDockWidget::task248604_infiniteResize()
{
#if defined Q_OS_BLACKBERRY
QSKIP("Top level window is stretched to fullscreen");
#endif
QDockWidget d;
QTabWidget *t = new QTabWidget;
t->addTab(new QWidget, "Foo");
d.setWidget(t);
d.setContentsMargins(2, 2, 2, 2);
d.setMinimumSize(320, 240);
d.showNormal();
QTest::qWait(400);
QCOMPARE(d.size(), QSize(320, 240));
}
示例3: sets
WindowImpl::WindowImpl():
m_ui(new Ui::WindowImpl)
{
m_ui->setupUi(this);
QApplication::setStyle(new QNotoStyle);
QSettings sets(QSettings::IniFormat, QSettings::UserScope, "qnoto", "qnoto");
restoreGeometry(sets.value("MainWindow/Geometry").toByteArray());
QDockWidget *dockWidget = new QDockWidget("Left side", this);
dockWidget->setContentsMargins(0, 0, 0, 0);
dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea);
dockWidget->setFloating(false);
dockWidget->setFeatures(dockWidget->features() ^ QDockWidget::DockWidgetClosable ^ QDockWidget::DockWidgetMovable ^ QDockWidget::DockWidgetFloatable);
dockWidget->setTitleBarWidget(new QWidget);
m_split = new SideSplit(this);
dockWidget->setWidget(m_split);
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
m_editors = qnoto::plugin<qnoto::Editors>();
connect(m_editors, &qnoto::Editors::updateEditMenu, this, &WindowImpl::updateEditMenu);
setCentralWidget(m_editors);
const auto& acts = m_editors->actions();
for(const auto& it: acts){
if (it->property("name").toString().startsWith("File_")){
m_ui->menuFile->addAction(it);
}
if (it->property("name").toString().startsWith("Window_")){
m_ui->menuWindow->addAction(it);
}
}
connect(m_ui->actionPreferences, &QAction::triggered, this, &WindowImpl::showPreferences);
m_split->restoreState(sets);
m_editors->restoreState();
}