当前位置: 首页>>代码示例>>C++>>正文


C++ QBoxLayout::margin方法代码示例

本文整理汇总了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
}
开发者ID:Aceler,项目名称:Clementine,代码行数:82,代码来源:osdpretty.cpp


注:本文中的QBoxLayout::margin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。