QCustomplot周边控件一些用法

一、QCPAxisRect

1.多个QCPAxisRect对齐:

         QCPAxisRect* R00 = new QCPAxisRect(m_pCustomPlot);
         QCPMarginGroup *marginGroup = new QCPMarginGroup(m_pCustomPlot);
         R00->setAutoMargins(QCP::MarginSide::msLeft | QCP::MarginSide::msRight);
         R00->setMarginGroup(QCP::msLeft | QCP::MarginSide::msRight, marginGroup); 

2.让QCPAxisRect四个轴都显示

        R00->setupFullAxesBox(true);

3.刻度号显示在内测

        R00->axis(QCPAxis::atBottom)->setTickLabelSide(QCPAxis::LabelSide::lsInside); 
        R00->axis(QCPAxis::atLeft)->setTickLabelSide(QCPAxis::LabelSide::lsInside);

4.QCPItemStraightLine展示在单个QCPAxisRect上

        auto pHorReffer = new QCPItemStraightLine(m_pCustomPlot);
        pHorReffer->setClipToAxisRect(true);
        pHorReffer->setClipAxisRect(R00);
        pHorReffer->point1->setAxes(R00->axis(QCPAxis::atBottom), R00->axis(QCPAxis::atLeft));
        pHorReffer->point2->setAxes(R00->axis(QCPAxis::atBottom), R00->axis(QCPAxis::atLeft));

二.QCPItemText

1.QCPItemText坐标依赖于软件位置

         this->position->setType(QCPItemPosition::ptAbsolute);

        设置用pixel坐标

2.QCPItemText坐标依赖于QCustomplot坐标

 this->position->setType(QCPItemPosition::ptPlotCoords);

        设置用coord坐标

三.qss设置

背景设置

1.图片大,控件小,图片显示不全

border-image: url(:/frontload/assets/images/oneUp.png);

使用border-image,不要用background-image

切换背景图:

样式表
QPushButton#pull-down,
QPushButton[classes~="pull-down"],
QPushButton {
    min-width: 100px;
    max-width: 100px;
    background: #F0F0F0;
    background-image: url(:/icon/pull-down.png);
    background-repeat: no-repeat;
    background-position: left center;
    color: black;
    border: 0px;
}

QPushButton#pull-right,
QPushButton[classes~="pull-right"],
QPushButton {
    min-width: 100px;
    max-width: 100px;
    background: #F0F0F0;
    background-image: url(:/icon/pull-right.png);
    background-repeat: no-repeat;
    background-position: left center;
    color: black;
    border: 0px;
}


代码
void ToolPlane::updataWgtStyle(QWidget* wgt, QString pro, QString val)
{
    if (wgt == nullptr) {
        return;
    }
    wgt->setProperty(pro.toStdString().c_str(), val);
    wgt->style()->unpolish(wgt); // 清除旧的样式
    wgt->style()->polish(wgt);   // 更新为新的样式
    wgt->update();
}

切换
updataWgtStyle(m_btnFold, "classes", "pull-down");
updataWgtStyle(m_btnFold, "classes", "pull-right");

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值