src/gui/graphicsview/qgraphicswidget.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 14 c0432d11811c
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
   322     \brief the size policy for the widget
   322     \brief the size policy for the widget
   323     \sa sizePolicy(), setSizePolicy(), QWidget::sizePolicy()
   323     \sa sizePolicy(), setSizePolicy(), QWidget::sizePolicy()
   324 */
   324 */
   325 
   325 
   326 /*!
   326 /*!
       
   327 
       
   328   \fn QGraphicsWidget::geometryChanged()
       
   329 
       
   330   This signal gets emitted whenever the geometry of the item changes
       
   331   \internal
       
   332 */
       
   333 
       
   334 /*!
   327     \property QGraphicsWidget::geometry
   335     \property QGraphicsWidget::geometry
   328     \brief the geometry of the widget
   336     \brief the geometry of the widget
   329 
   337 
   330     Sets the item's geometry to \a rect. The item's position and size are
   338     Sets the item's geometry to \a rect. The item's position and size are
   331     modified as a result of calling this function. The item is first moved,
   339     modified as a result of calling this function. The item is first moved,
   332     then resized.
   340     then resized.
   333 
   341 
   334     A side effect of calling this function is that the widget will receive
   342     A side effect of calling this function is that the widget will receive
   335     a move event and a resize event. Also, if the widget has a layout
   343     a move event and a resize event. Also, if the widget has a layout
   336     assigned, the layout will activate.
   344     assigned, the layout will activate.
   337     
   345 
   338     \sa geometry(), resize()
   346     \sa geometry(), resize()
   339 */
   347 */
   340 void QGraphicsWidget::setGeometry(const QRectF &rect)
   348 void QGraphicsWidget::setGeometry(const QRectF &rect)
   341 {
   349 {
   342     QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
   350     QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
   382             return;
   390             return;
   383         }
   391         }
   384     }
   392     }
   385     QSizeF oldSize = size();
   393     QSizeF oldSize = size();
   386     QGraphicsLayoutItem::setGeometry(newGeom);
   394     QGraphicsLayoutItem::setGeometry(newGeom);
   387 
   395     emit geometryChanged();
   388     // Send resize event
   396     // Send resize event
   389     bool resized = newGeom.size() != oldSize;
   397     bool resized = newGeom.size() != oldSize;
   390     if (resized) {
   398     if (resized) {
   391         QGraphicsSceneResizeEvent re;
   399         QGraphicsSceneResizeEvent re;
   392         re.setOldSize(oldSize);
   400         re.setOldSize(oldSize);
   393         re.setNewSize(newGeom.size());
   401         re.setNewSize(newGeom.size());
       
   402         if (oldSize.width() != newGeom.size().width())
       
   403             emit widthChanged();
       
   404         if (oldSize.height() != newGeom.size().height())
       
   405             emit heightChanged();
   394         QApplication::sendEvent(this, &re);
   406         QApplication::sendEvent(this, &re);
   395     }
   407     }
   396 }
   408 }
   397 
   409 
   398 /*!
   410 /*!
   560     \sa setWindowFrameMargins(), getWindowFrameMargins(), windowFrameRect()
   572     \sa setWindowFrameMargins(), getWindowFrameMargins(), windowFrameRect()
   561 */
   573 */
   562 void QGraphicsWidget::unsetWindowFrameMargins()
   574 void QGraphicsWidget::unsetWindowFrameMargins()
   563 {
   575 {
   564     Q_D(QGraphicsWidget);
   576     Q_D(QGraphicsWidget);
   565     if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup && 
   577     if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup &&
   566          (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) {
   578          (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) {
   567         QStyleOptionTitleBar bar;
   579         QStyleOptionTitleBar bar;
   568         d->initStyleOptionTitleBar(&bar);
   580         d->initStyleOptionTitleBar(&bar);
   569         QStyle *style = this->style();
   581         QStyle *style = this->style();
   570         qreal margin = style->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth);
   582         qreal margin = style->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth);
  1137     You can reimplement this handler in a subclass of QGraphicsWidget to
  1149     You can reimplement this handler in a subclass of QGraphicsWidget to
  1138     provide your own custom window frame interaction support.
  1150     provide your own custom window frame interaction support.
  1139 
  1151 
  1140     Returns true if \a event has been recognized and processed; otherwise,
  1152     Returns true if \a event has been recognized and processed; otherwise,
  1141     returns false.
  1153     returns false.
  1142     
  1154 
  1143     \sa event()
  1155     \sa event()
  1144 */
  1156 */
  1145 bool QGraphicsWidget::windowFrameEvent(QEvent *event)
  1157 bool QGraphicsWidget::windowFrameEvent(QEvent *event)
  1146 {
  1158 {
  1147     Q_D(QGraphicsWidget);
  1159     Q_D(QGraphicsWidget);
  1194     Q_D(const QGraphicsWidget);
  1206     Q_D(const QGraphicsWidget);
  1195 
  1207 
  1196     const QRectF r = windowFrameRect();
  1208     const QRectF r = windowFrameRect();
  1197     if (!r.contains(pos))
  1209     if (!r.contains(pos))
  1198         return Qt::NoSection;
  1210         return Qt::NoSection;
  1199     
  1211 
  1200     const qreal left = r.left();
  1212     const qreal left = r.left();
  1201     const qreal top = r.top();
  1213     const qreal top = r.top();
  1202     const qreal right = r.right();
  1214     const qreal right = r.right();
  1203     const qreal bottom = r.bottom();
  1215     const qreal bottom = r.bottom();
  1204     const qreal x = pos.x();
  1216     const qreal x = pos.x();
  2320     } while (next != this);
  2332     } while (next != this);
  2321 }
  2333 }
  2322 #endif
  2334 #endif
  2323 
  2335 
  2324 QT_END_NAMESPACE
  2336 QT_END_NAMESPACE
  2325         
  2337 
  2326 #endif //QT_NO_GRAPHICSVIEW
  2338 #endif //QT_NO_GRAPHICSVIEW