64void Spacer::paintEvent(QPaintEvent *)
67 if (m_formWindow !=
nullptr && m_formWindow->currentTool() != 0)
72 const int w = width();
73 const int h = height();
77 if (w <= m_SizeOffset.width() || h <= m_SizeOffset.height()) {
80 switch (m_orientation) {
82 p.drawLine(0, 0, 0, lh);
83 p.drawLine(lw, 0, lw, lh);
86 p.drawLine(0, 0, lw, 0);
87 p.drawLine(0, lh, lw, lh);
92 if (m_orientation == Qt::Horizontal) {
94 const int amplitude = qMin(3, h / 3);
95 const int base = h / 2;
98 for (i = 0; i < w / 3 +2; ++i)
99 p.drawLine(i * dist, base - amplitude, i * dist + dist / 2, base + amplitude);
101 for (i = 0; i < w / 3 +2; ++i)
102 p.drawLine(i * dist + dist / 2, base + amplitude, i * dist + dist, base - amplitude);
104 p.drawLine(0, y-10, 0, y+10);
105 p.drawLine(w - 1, y-10, w - 1, y+10);
108 const int amplitude = qMin(3, w / 3);
109 const int base = w / 2;
112 for (i = 0; i < h / 3 +2; ++i)
113 p.drawLine(base - amplitude, i * dist, base + amplitude,i * dist + dist / 2);
115 for (i = 0; i < h / 3 +2; ++i)
116 p.drawLine(base + amplitude, i * dist + dist / 2, base - amplitude, i * dist + dist);
118 p.drawLine(x-10, 0, x+10, 0);
119 p.drawLine(x-10, h - 1, x+10, h - 1);
123void Spacer::resizeEvent(QResizeEvent* e)
125 QWidget::resizeEvent(e);
129 const QSize oldSize = e->oldSize();
130 if (oldSize.isNull() || oldSize.width() <= m_SizeOffset.width() || oldSize.height() <= m_SizeOffset.height())
131 if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(m_formWindow->core()->extensionManager(),
this))
132 sheet->setChanged(sheet->indexOf(u"sizeHint"_s),
true);
141 const QSize currentSize = size();
142 if (currentSize.width() >= m_SizeOffset.width() && currentSize.height() >= m_SizeOffset.height())
143 m_sizeHint = currentSize - m_SizeOffset;
147void Spacer::updateMask()
150 const int w = width();
151 const int h = height();
152 if (w > 1 && h > 1) {
153 if (m_orientation == Qt::Horizontal) {
154 const int amplitude = qMin(3, h / 3);
155 const int base = h / 2;
156 r = r.subtracted(QRect(1, 0, w - 2, base - amplitude));
157 r = r.subtracted(QRect(1, base + amplitude, w - 2, h - base - amplitude));
159 const int amplitude = qMin(3, w / 3);
160 const int base = w / 2;
161 r = r.subtracted(QRect(0, 1, base - amplitude, h - 2));
162 r = r.subtracted(QRect(base + amplitude, 1, w - base - amplitude, h - 2));
211void Spacer::setOrientation(Qt::Orientation o)
213 if (m_orientation == o)
216 const QSizePolicy::Policy st = sizeType();
221 m_sizeHint = QSize(m_sizeHint.height(), m_sizeHint.width());
223 resize(m_sizeHint + m_SizeOffset);