本文整理汇总了C++中QBoxLayout::margin方法的典型用法代码示例。如果您正苦于以下问题:C++ QBoxLayout::margin方法的具体用法?C++ QBoxLayout::margin怎么用?C++ QBoxLayout::margin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBoxLayout
的用法示例。
在下文中一共展示了QBoxLayout::margin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shadow_edge
OSDPretty::OSDPretty(Mode mode, QWidget* parent)
: QWidget(parent),
ui_(new Ui_OSDPretty),
mode_(mode),
background_color_(kPresetBlue),
background_opacity_(0.85),
popup_display_(0),
font_(QFont()),
disable_duration_(false),
timeout_(new QTimer(this)),
fading_enabled_(false),
fader_(new QTimeLine(300, this)),
toggle_mode_(false) {
Qt::WindowFlags flags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint |
Qt::X11BypassWindowManagerHint;
setWindowFlags(flags);
setAttribute(Qt::WA_TranslucentBackground, true);
setAttribute(Qt::WA_X11NetWmWindowTypeNotification, true);
setAttribute(Qt::WA_ShowWithoutActivating, true);
ui_->setupUi(this);
#ifdef Q_OS_WIN32
// Don't show the window in the taskbar. Qt::ToolTip does this too, but it
// adds an extra ugly shadow.
int ex_style = GetWindowLong(winId(), GWL_EXSTYLE);
ex_style |= WS_EX_NOACTIVATE;
SetWindowLong(winId(), GWL_EXSTYLE, ex_style);
#endif
// Mode settings
switch (mode_) {
case Mode_Popup:
setCursor(QCursor(Qt::ArrowCursor));
break;
case Mode_Draggable:
setCursor(QCursor(Qt::OpenHandCursor));
break;
}
// Timeout
timeout_->setSingleShot(true);
timeout_->setInterval(5000);
connect(timeout_, SIGNAL(timeout()), SLOT(hide()));
ui_->icon->setMaximumSize(kMaxIconSize, kMaxIconSize);
// Fader
connect(fader_, SIGNAL(valueChanged(qreal)), SLOT(FaderValueChanged(qreal)));
connect(fader_, SIGNAL(finished()), SLOT(FaderFinished()));
#ifdef Q_OS_WIN32
set_fading_enabled(true);
#endif
// Load the show edges and corners
QImage shadow_edge(":osd_shadow_edge.png");
QImage shadow_corner(":osd_shadow_corner.png");
for (int i = 0; i < 4; ++i) {
QTransform rotation = QTransform().rotate(90 * i);
shadow_edge_[i] = QPixmap::fromImage(shadow_edge.transformed(rotation));
shadow_corner_[i] = QPixmap::fromImage(shadow_corner.transformed(rotation));
}
background_ = QPixmap(":osd_background.png");
// Set the margins to allow for the drop shadow
QBoxLayout* l = static_cast<QBoxLayout*>(layout());
int margin = l->margin() + kDropShadowSize;
l->setMargin(margin);
// Get current screen resolution
QRect screenResolution = QApplication::desktop()->screenGeometry();
// Leave 200 px for icon
ui_->summary->setMaximumWidth(screenResolution.width() - 200);
ui_->message->setMaximumWidth(screenResolution.width() - 200);
// Set maximum size for the OSD, a little margin here too
setMaximumSize(screenResolution.width() - 100,
screenResolution.height() - 100);
// Don't load settings here, they will be reloaded anyway on creation
}