示例#1
0
/*!
    \fn virtual void QGraphicsLayoutItem::setGeometry(const QRectF &rect)

    This virtual function sets the geometry of the QGraphicsLayoutItem to
    \a rect, which is in parent coordinates (e.g., the top-left corner of \a rect
    is equivalent to the item's position in parent coordinates).

    You must reimplement this function in a subclass of QGraphicsLayoutItem to
    receive geometry updates. The layout will call this function when it does a 
    rearrangement.

    If \a rect is outside of the bounds of minimumSize and maximumSize, it
    will be adjusted to its closest size so that it is within the legal
    bounds.

    \sa geometry()
*/
void QGraphicsLayoutItem::setGeometry(const QRectF &rect)
{
    Q_D(QGraphicsLayoutItem);
    QSizeF effectiveSize = rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
                                .boundedTo(effectiveSizeHint(Qt::MaximumSize));
    d->geom = QRectF(rect.topLeft(), effectiveSize);
}
示例#2
0
int QGraphicsLayoutItem_effectiveSizeHint(lua_State* const state)
{
    // QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF()) const
    auto self = lua::get<QGraphicsLayoutItem*>(state, 1);
    if (lua_gettop(state) == 2) {
        lua::push(state, self->effectiveSizeHint(
            lua::get<Qt::SizeHint>(state, 2)
        ));
    } else {
        lua::push(state, self->effectiveSizeHint(
            lua::get<Qt::SizeHint>(state, 2),
            lua::get<const QSizeF&>(state, 3)
        ));
    }
    return 1;
}
void HeaderedTextEdit::setHeaderText(const QString &text)
{
    if (!headerLabel) {
        headerLabel = new MLabel(this);
        headerLabel->setObjectName("headerLabel");
        headerLabel->setStyleName("CommonEditorInputFieldLabel");
        headerLabel->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
        headerLabel->setPos(0, 0);
        headerLabel->setPreferredHeight(effectiveSizeHint(Qt::PreferredSize).height());
        headerLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    }
    headerLabel->setText(text);

    updateTextLeftMargin();
}
示例#4
0
/*!
    Returns the maximum size.

    \sa setMaximumSize(), minimumSize(), preferredSize(), Qt::MaximumSize,
    sizeHint()
*/
QSizeF QGraphicsLayoutItem::maximumSize() const
{
    return effectiveSizeHint(Qt::MaximumSize);
}
示例#5
0
/*!
    Returns the preferred size.

    \sa setPreferredSize(), minimumSize(), maximumSize(), Qt::PreferredSize,
    sizeHint()
*/
QSizeF QGraphicsLayoutItem::preferredSize() const
{
    return effectiveSizeHint(Qt::PreferredSize);
}