BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
CautionSignWidget Class Reference

Description

The CautionSignWidget is an transparent widget with caution sign pixmap intended to be overlayed onto other widget at some arbitrary position.

Definition at line 24 of file CautionSignWidget.h.

Inheritance diagram for CautionSignWidget:
[legend]
Collaboration diagram for CautionSignWidget:
[legend]

Public Member Functions

 CautionSignWidget (QWidget *parent=nullptr)
 
void setCautionHeader (const QString &message)
 
void setCautionMessage (const QString &message)
 
void setPosition (int x, int y)
 set geometry of widget around center point More...
 

Protected Member Functions

void mousePressEvent (QMouseEvent *event) override
 
void paintEvent (QPaintEvent *event) override
 

Private Attributes

QString m_caution_header
 
QString m_caution_message
 
QPixmap m_pixmap
 

Constructor & Destructor Documentation

◆ CautionSignWidget()

CautionSignWidget::CautionSignWidget ( QWidget *  parent = nullptr)

Definition at line 20 of file CautionSignWidget.cpp.

21  : QWidget(parent)
22  , m_pixmap(":/images/warning@2x.png")
23  , m_caution_header("Houston, we have a problem.")
24 {
25  setAttribute(Qt::WA_NoSystemBackground);
26  setToolTip(m_caution_header + "\nClick to see details.");
27 }

References m_caution_header.

Member Function Documentation

◆ mousePressEvent()

void CautionSignWidget::mousePressEvent ( QMouseEvent *  event)
overrideprotected

Definition at line 37 of file CautionSignWidget.cpp.

38 {
39  Q_UNUSED(event);
40  QMessageBox box;
41  box.setWindowTitle(m_caution_header);
42  box.setInformativeText(m_caution_message);
43  box.setStandardButtons(QMessageBox::Ok);
44  box.setDefaultButton(QMessageBox::Ok);
45  box.exec();
46 }

References m_caution_header, and m_caution_message.

◆ paintEvent()

void CautionSignWidget::paintEvent ( QPaintEvent *  event)
overrideprotected

Definition at line 29 of file CautionSignWidget.cpp.

30 {
31  Q_UNUSED(event);
32  QPainter painter(this);
33  QRect target(m_pixmap.rect());
34  painter.drawPixmap(target, m_pixmap);
35 }

References m_pixmap.

◆ setCautionHeader()

void CautionSignWidget::setCautionHeader ( const QString &  message)

Definition at line 54 of file CautionSignWidget.cpp.

55 {
56  m_caution_header = message;
57  setToolTip(m_caution_header + "\nClick to see details.");
58 }

References m_caution_header.

◆ setCautionMessage()

void CautionSignWidget::setCautionMessage ( const QString &  message)
inline

Definition at line 31 of file CautionSignWidget.h.

31 { m_caution_message = message; }

References m_caution_message.

Referenced by CautionSign::setCautionMessage().

◆ setPosition()

void CautionSignWidget::setPosition ( int  x,
int  y 
)

set geometry of widget around center point

Definition at line 49 of file CautionSignWidget.cpp.

50 {
51  setGeometry(x, y, m_pixmap.width(), m_pixmap.height());
52 }

References m_pixmap.

Referenced by CautionSign::updateLabelGeometry().

Member Data Documentation

◆ m_caution_header

QString CautionSignWidget::m_caution_header
private

Definition at line 39 of file CautionSignWidget.h.

Referenced by CautionSignWidget(), mousePressEvent(), and setCautionHeader().

◆ m_caution_message

QString CautionSignWidget::m_caution_message
private

Definition at line 40 of file CautionSignWidget.h.

Referenced by mousePressEvent(), and setCautionMessage().

◆ m_pixmap

QPixmap CautionSignWidget::m_pixmap
private

Definition at line 38 of file CautionSignWidget.h.

Referenced by paintEvent(), and setPosition().


The documentation for this class was generated from the following files: