量化交易之QT篇 - TQZBanView

// TQZBanView.h

#ifndef TQZBANVIEW_H
#define TQZBANVIEW_H

#include <QWidget>
#include <QGraphicsView>

#include "TQZButton.h"
#include <QComboBox>


class TQZBanView : public QGraphicsView
{
    Q_OBJECT
public:
    explicit TQZBanView(double width, QWidget *parent = nullptr);

    TQZButton *banButton();
    QComboBox *accountsComboBox();
    TQZButton *messageButton();

private:
    TQZButton *m_banButton;
    QComboBox *m_accountsComboBox;
    TQZButton *m_messageButton;

    double m_inner_widget_height;
    double m_width;
    double m_height;

signals:

};

#endif // TQZBANVIEW_H
// TQZBanView.cpp

#include "TQZBanView.h"


TQZBanView::TQZBanView(double width, QWidget *parent):
    QGraphicsView(parent),
    m_banButton(nullptr),
    m_accountsComboBox(nullptr),
    m_messageButton(nullptr),
    m_inner_widget_height(35),
    m_width(width),
    m_height(m_inner_widget_height * 2 + 10) // 10 is edge.
{
    this->setFixedSize(this->m_width, this->m_height);
    this->setStyleSheet("background: transparent");
}


TQZButton *TQZBanView::banButton() {
    if (this->m_banButton == nullptr) {
        this->m_banButton = new TQZButton("lock", TQZButtonType::LOCK, this);
        m_banButton->setFixedSize((this->width() - 10) * 2 / 7, this->m_inner_widget_height);
    }

    return this->m_banButton;
}


QComboBox *TQZBanView::accountsComboBox() {
    if (this->m_accountsComboBox == nullptr) {
        this->m_accountsComboBox = new QComboBox(this);
        this->m_accountsComboBox->setFixedSize((this->width() - 10) * 5 / 7, this->m_inner_widget_height);
        this->m_accountsComboBox->move(this->width() - this->m_accountsComboBox->width(), 0);
        this->m_accountsComboBox->setStyleSheet("background-color: white; selection-background-color: red;");
    }

    return this->m_accountsComboBox;
}

TQZButton *TQZBanView::messageButton() {
    if (this->m_messageButton == nullptr) {
        this->m_messageButton = new TQZButton("message", TQZButtonType::MESSAGE, this);
        this->m_messageButton->setFixedSize(this->width(), this->m_inner_widget_height);
        this->m_messageButton->move(0, this->height() - this->m_messageButton->height());

        this->m_messageButton->connect(this->m_messageButton, &TQZButton::clicked, this, [=](){
            this->m_messageButton->setText("message");
        });
    }

    return this->m_messageButton;
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值