PopupMessage::PopupMessage(QWidget *parent, QWidget *anchor, int timeout)
  : OverlayWidget(parent, anchor),
    m_anchor(anchor),
    m_parent(parent),
    m_maskEffect(Slide),
    m_dissolveSize(0),
    m_dissolveDelta(-1),
    m_offset(0),
    m_counter(0),
    m_stage(1),
    m_timeout(timeout)
{
  setFrameStyle(QFrame::StyledPanel);
  setWindowFlags(Qt::WX11BypassWM);
  setMinimumSize(360, 78);

  QPalette p = QToolTip::palette();
  setPalette(p);
  setAutoFillBackground(true);

  QHBoxLayout *hbox;
  QLabel *label;
  QLabel *alabel;

  m_layout = new QVBoxLayout(this);
  m_layout->setMargin(5);
  m_layout->setSpacing(5);
  
  hbox = new QHBoxLayout();
  hbox->setParent(m_layout);
  hbox->setSpacing(12);
  m_layout->addLayout(hbox);

  // Setup the icon widget
  m_icon = new QLabel(this);
  hbox->addWidget(m_icon);

  // Setup the text widget
  m_text = new QLabel(this);
  m_text->setTextFormat(Qt::RichText);
  m_text->setWordWrap(true);
  m_text->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
  m_text->setPalette(p);
  hbox->addWidget(m_text);

  hbox = new QHBoxLayout();
  hbox->setParent(m_layout);
  hbox->addItem(new QSpacerItem(4, 4, QSizePolicy::Expanding, QSizePolicy::Preferred));
  m_layout->addLayout(hbox);
  
  m_close = new KPushButton(KStandardGuiItem::close(), this);
  hbox->addWidget(m_close);
  connect(m_close, SIGNAL(clicked()), SLOT(close()));
}
示例#2
0
void tst_QLayout::warnIfWrongParent()
{
    QWidget root;
    QHBoxLayout lay;
    lay.setParent(&root);
    QTest::ignoreMessage(QtWarningMsg, "QLayout::parentWidget: A layout can only have another layout as a parent.");
    QCOMPARE(lay.parentWidget(), static_cast<QWidget*>(0));
}