当前位置: 首页>>代码示例>>C++>>正文


C++ QMargins类代码示例

本文整理汇总了C++中QMargins的典型用法代码示例。如果您正苦于以下问题:C++ QMargins类的具体用法?C++ QMargins怎么用?C++ QMargins使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QMargins类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: saveInSettings

void saveInSettings(QSettings& settingsObj, const QString &name, const QMargins  &value)
{
    settingsObj.setValue(name + "/left", value.left());
    settingsObj.setValue(name + "/top", value.top());
    settingsObj.setValue(name + "/right", value.right());
    settingsObj.setValue(name + "/bottom", value.bottom());
}
开发者ID:seleznevae,项目名称:JaG,代码行数:7,代码来源:settings.cpp

示例2: getLayoutInfo

QString LayoutDumper::getLayoutInfo(QLayout* layout)
{
    if (!layout) {
        return "null_layout";
    }
    QMargins margins = layout->contentsMargins();
    QSize sizehint = layout->sizeHint();
    QSize minsize = layout->minimumSize();
    QString name = layout->metaObject()->className();
    // usually unhelpful (blank): layout->objectName()
    QString margin = QString("margin (l=%1,t=%2,r=%3,b=%4)")
            .arg(margins.left())
            .arg(margins.top())
            .arg(margins.right())
            .arg(margins.bottom());
    QString constraint = QString("constraint %1")
            .arg(toString(layout->sizeConstraint()));
    QString sh = QString("sizeHint (%1 x %2)")
            .arg(sizehint.width())
            .arg(sizehint.height());
    QString ms = QString("minimumSize (%7 x %8)")
            .arg(minsize.width())
            .arg(minsize.height());
    QString hfw = layout->hasHeightForWidth() ? " [hasHeightForWidth]" : "";
    return QString("%1, %2, %3, %4, %5%6")
            .arg(name)
            .arg(margin)
            .arg(constraint)
            .arg(sh)
            .arg(ms)
            .arg(hfw);
}
开发者ID:RudolfCardinal,项目名称:camcops,代码行数:32,代码来源:layoutdumper.cpp

示例3: contentsMargins

QSize TrayIcon::sizeHint() const
{
    QMargins margins = contentsMargins();
    return QSize(margins.left() + mIconSize.width() + margins.right(),
                 margins.top() + mIconSize.height() + margins.bottom()
                );
}
开发者ID:Devoter,项目名称:razor-qt,代码行数:7,代码来源:trayicon.cpp

示例4: painter

void LineEdit::paintEvent(QPaintEvent* event)
{
    QLineEdit::paintEvent(event);

	if(hasIcon()) {
		QPainter painter(this);
		painter.drawPixmap(3, 2, icon_);
	}

	QPainter painter(this);
	QFontMetrics fm(font());
	QMargins margins = textMargins();

	if(!prefix_.isEmpty()) {
		int x = margins.left() - fm.width(prefix_) + 4;
		int y = margins.top() + fm.height();

		painter.setPen(prefixColor_);
		painter.drawText(x, y, prefix_);
	}

	if(!suffix_.isEmpty()) {
		int x = width() - margins.right();
		int y = margins.top() + fm.height();

		painter.setPen(suffixColor_);
		painter.drawText(x, y, suffix_);
	}
}
开发者ID:EQ4,项目名称:airwave,代码行数:29,代码来源:lineedit.cpp

示例5: textMargins

void LineEdit::setRightIcon(const QPixmap & icon)
{
	rightIcon_ = icon;
	QMargins margins = textMargins();
	margins.setRight(icon.width() + 6);
	setTextMargins(margins);
}
开发者ID:choenig,项目名称:tingy,代码行数:7,代码来源:lineedit.cpp

示例6: maxMargins

void Map::adjustDrawMargins(const QMargins &margins) {
    mDrawMargins = maxMargins(QMargins(margins.left(),
                                       margins.top() - mTileHeight,
                                       margins.right() - mTileWidth,
                                       margins.bottom()),
                              mDrawMargins);
}
开发者ID:ATSOTECK,项目名称:Aurora-Game-Editor,代码行数:7,代码来源:map.cpp

示例7: QToolBar

BaseToolBar::BaseToolBar(const QString& title, QWidget* parent) : QToolBar(title, parent) {
  // Update right margin of filter textbox.
  QMargins margins = contentsMargins();

  margins.setRight(margins.right() + FILTER_RIGHT_MARGIN);
  setContentsMargins(margins);
}
开发者ID:martinrotter,项目名称:rssguard,代码行数:7,代码来源:basetoolbar.cpp

示例8: setMargins

void KWidget::setMargins( const QMargins& m )
{
    QGraphicsLayout *tmpLayout = layout();
    if(tmpLayout == NULL)
        return;
    tmpLayout->setContentsMargins(m.left(), m.top(), m.right(), m.bottom());
}
开发者ID:kxtry,项目名称:kxmob,代码行数:7,代码来源:kwidget.cpp

示例9: setMargins

void HGLayout::setMargins(const QMargins& m)
{
    if (layout()) {
        layout()->setContentsMargins(m.left(), m.top(), m.right(), m.bottom());
    }
    HLayout::setMargins(m);
}
开发者ID:huqiuyun,项目名称:qt.project,代码行数:7,代码来源:hglayout.cpp

示例10: QWidget

QWidget * ExtcapArgumentFileSelection::createEditor(QWidget * parent)
{
    QWidget * fileWidget = new QWidget(parent);
    QHBoxLayout * editLayout = new QHBoxLayout();
    QMargins margins = editLayout->contentsMargins();
    editLayout->setContentsMargins(0, 0, 0, margins.bottom());
    fileWidget->setContentsMargins(margins.left(), margins.right(), 0, margins.bottom());
    QPushButton * button = new QPushButton(UTF8_HORIZONTAL_ELLIPSIS, fileWidget);

    textBox = new QLineEdit(_default->toString(), parent);
    textBox->setReadOnly(true);

    if ( _argument->default_complex != NULL && _argument->arg_type == EXTCAP_ARG_STRING )
        textBox->setText(QString().fromUtf8(extcap_complex_get_string(_argument->default_complex)));

    if ( _argument->tooltip != NULL )
    {
        textBox->setToolTip(QString().fromUtf8(_argument->tooltip));
        button->setToolTip(QString().fromUtf8(_argument->tooltip));
    }


    connect(button, SIGNAL(clicked()), (QObject *)this, SLOT(openFileDialog()));

    editLayout->addWidget(textBox);
    editLayout->addWidget(button);

    fileWidget->setLayout(editLayout);

    return fileWidget;
}
开发者ID:Nicholas1126,项目名称:wireshark-ex,代码行数:31,代码来源:extcap_argument_file.cpp

示例11: layout

QRect WWidgetGroup::layoutContentsMargins() const {
    QLayout* pLayout = layout();
    QMargins margins = pLayout ? pLayout->contentsMargins() :
            contentsMargins();
    return QRect(margins.left(), margins.top(),
                 margins.right(), margins.bottom());
}
开发者ID:suyoghc,项目名称:mixxx,代码行数:7,代码来源:wwidgetgroup.cpp

示例12: contentsMargins

void DragTool::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton) {
        const QMargins margins = contentsMargins();
        const QRect iconRect((width() - d->iconSize.width()) / 2, margins.top(),
                       d->iconSize.width(), d->iconSize.height());
        if (iconRect.contains(event->pos())) {
            auto drag = new QDrag(this);
            auto mimeData = new QMimeData;
            QByteArray data;
            QDataStream dataStream(&data, QIODevice::WriteOnly);
            dataStream << d->newElementId << d->title << d->stereotype;
            mimeData->setData(QLatin1String(qmt::MIME_TYPE_NEW_MODEL_ELEMENTS), data);
            drag->setMimeData(mimeData);

            QPixmap pixmap = d->icon.pixmap(d->iconSize, QIcon::Normal, QIcon::Off);
            QPainter painter(&pixmap);
            painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
            painter.fillRect(pixmap.rect(), QColor(0, 0, 0, 96));
            drag->setPixmap(pixmap);
            drag->setHotSpot(QPoint(drag->pixmap().width() / 2, drag->pixmap().height() / 2));

            d->disableFrame = true;
            update();
            Qt::DropAction dropAction = drag->exec();
            Q_UNUSED(dropAction);
            d->disableFrame = false;
            update();
        }
    }
}
开发者ID:C-sjia,项目名称:qt-creator,代码行数:31,代码来源:dragtool.cpp

示例13: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    setupUi(this);

    // add the settings slide out panel
    controlPanel = new ControlPanel(this->centralWidget());

    QMargins mainMargins =  m_verticalLayout->contentsMargins();
    controlPanel->setLeftMargin(mainMargins.left());

    //show the controlPanel
    controlPanel->show();
    // slide this panel to the top
    controlPanel->collapse();

    // make sure there is enough room for the controls
    int minWidth = controlPanel->frameGeometry().width();
    if( minWidth > m_mainSplitter->minimumWidth())
        m_mainSplitter->setMinimumWidth(minWidth);


    // make sure there is enough space for the collapsed panel
    // above all other widgets
    int hHeight = controlPanel->hiddenHeight();
    qDebug() << Q_FUNC_INFO << "calculated height: " << hHeight;
    mainMargins.setTop(hHeight);
    m_verticalLayout->setContentsMargins(mainMargins);
    m_mainSplitter->installEventFilter(this);

}
开发者ID:cyc1ingsir,项目名称:SlidingControlPanel,代码行数:31,代码来源:mainwindow.cpp

示例14: fromScriptValue

void NMarginsPrototype::fromScriptValue(const QScriptValue &obj, QMargins &m)
{
	m.setBottom(obj.property("bottom").toInt32());
	m.setLeft(obj.property("left").toInt32());
	m.setRight(obj.property("right").toInt32());
	m.setTop(obj.property("top").toInt32());
}
开发者ID:vkolev,项目名称:nulloy,代码行数:7,代码来源:scriptPrototypes.cpp

示例15: Q_UNUSED

void DragTool::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QMargins margins = contentsMargins();
    QPixmap pixmap = d->icon.pixmap(d->iconSize, isEnabled() ? QIcon::Normal : QIcon::Disabled, QIcon::Off);
    QPainter painter(this);
    QRect targetRect((width() - pixmap.width()) / 2,
                     margins.top() + (d->iconSize.height() - pixmap.height()) / 2,
                     pixmap.width(),
                     pixmap.height());
    QRect sourceRect(0, 0, pixmap.width(), pixmap.height());
    painter.drawPixmap(targetRect, pixmap, sourceRect);

    QRect textRect = painter.boundingRect(QRect(), Qt::AlignLeft | Qt::TextSingleLine, d->title);
    QRect boundingRect(0, d->iconSize.height(), width(), textRect.height());
    painter.drawText(boundingRect, Qt::AlignHCenter | Qt::TextSingleLine, d->title);

    // draw a weak frame if mouse is inside widget
    if (!d->disableFrame && rect().contains(QWidget::mapFromGlobal(QCursor::pos()))) {
        QRect rect(0, 0, width() - 1, height() - 1);
        QPen pen = painter.pen();
        pen.setStyle(Qt::DotLine);
        painter.setPen(pen);
        painter.drawRect(rect);
        d->framePainted = true;
    } else {
        d->framePainted = false;
    }
}
开发者ID:C-sjia,项目名称:qt-creator,代码行数:29,代码来源:dragtool.cpp


注:本文中的QMargins类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。