QTableView使用示例-Qt模型视图委托(MVD)(Model-View-Delegate)

news2024/9/19 9:21:04

         模型视图委托(MVD)是Qt中特有的设计模式,类似MVC设计模式,将MVC设计模式中的Controller当做MVD中的Delegate,两者的概念基本相同。不同的是委托不是独立存在,而是包含在视图里面。 模型视图委托设计模式中,模型负责存储和管理数据;视图负责显示数据,其中界面的框架和基础信息是视图负责,具体数据的显示是委托负责;委托不仅仅负责数据的显示,还有一个重要的功能是负责数据的编辑,如在视图中双击就可以编辑数据。

一、MVD简介

        QT当中model-view-delegate(模型-视图-代理),此结构实现数据和界面的分离。

        Qt的模型-视图结构分为三部分:模型(mode)-视图(view)-代理(Delegate) ,其中模型与数据源通信,并为其它部件提供接口;视图从模型中引用数据条的模型索引(Modellndex),在视图当中,代理负责绘制数据条目,比如编辑条目,代理和模型进行直接通信。

1、模型 (model): 实现自定义模型可以通过QAbstractltemModel类继承,也可以通过QAbstractListModel和QAbstractTableModel类继承实现列表模型或者表格模型
2、视图(view): 实现自定义的视图View,可以继承子QAbstractltemView类,对所需要的虚拟函数进行重定义。

3、代理 (delegate) :在表格当中嵌入各种不同的控件,通过表格中控件对编辑的内容进行操作。表格插入控件方式,控件始终显示。

二、简述

         本实例基于QT的委托代理机制实现的Qt模型视图代理(Model-View-Delegate)使用示例。以QTableView为基础,实现表头排序,列表复选框,插入按钮、下拉框、进度条。在Qt中,QTableView是一个用于显示表格数据的控件,可以使用Qt的模型视图代理(Model-View-Delegate)设计模式来定制QTableView的外观和行为。

三、效果 

四、核心代码  

student.h 学生信息

#ifndef STUDENT_H
#define STUDENT_H

#include <QtCore>

struct Student
{
    bool checked = false;
    quint16 id = 0;
    QString name;
    quint16 age = 0;
    QString gender = QObject::tr("男");
    quint16 achievement= 0;
    qint16 process = 50;
};

Q_DECLARE_METATYPE(Student);//将自定义类型声明为元类型(MetaType),以便在信号与槽机制中通过传递
Q_DECLARE_METATYPE(Student*);

#endif // STUDENT_H
1、下拉框委托类

comboboxdelegate.h

#ifndef COMBOBOXDELEGATE_H
#define COMBOBOXDELEGATE_H

#include <QStyledItemDelegate>

//下拉框委托类
class ComboBoxDelegate : public QStyledItemDelegate
{
    Q_OBJECT
public:
    explicit ComboBoxDelegate(QObject *parent = nullptr)
        : QStyledItemDelegate(parent)
    {}

protected:
    QWidget *createEditor(QWidget *parent,
                          const QStyleOptionViewItem &,
                          const QModelIndex &) const Q_DECL_OVERRIDE;
    void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE;
    void setModelData(QWidget *editor,
                      QAbstractItemModel *model,
                      const QModelIndex &index) const Q_DECL_OVERRIDE;
};

#endif // COMBOBOXDELEGATE_H

 comboboxdelegate.cpp

#include "comboboxdelegate.h"
#include "student.h"

#include <QtWidgets>

QWidget *ComboBoxDelegate::createEditor(QWidget *parent,
                                        const QStyleOptionViewItem &,
                                        const QModelIndex &) const
{
    QComboBox *comboBox = new QComboBox(parent);
    comboBox->addItems(QStringList() << tr("男") << tr("女"));
    return comboBox;
}

void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
    comboBox->setCurrentIndex(index.data(Qt::EditRole).toInt());
}

void ComboBoxDelegate::setModelData(QWidget *editor,
                                    QAbstractItemModel *model,
                                    const QModelIndex &index) const
{
    QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
    model->setData(index, comboBox->currentText(), Qt::EditRole);
}
2、按钮委托类

buttondelegate.h

#ifndef BUTTONDELEGATE_H
#define BUTTONDELEGATE_H

#include <QStyledItemDelegate>

//按钮委托类
class ButtonDelegate : public QStyledItemDelegate
{
public:
    ButtonDelegate(QObject* parent = nullptr);

    void paint(QPainter *painter,
               const QStyleOptionViewItem &option,
               const QModelIndex &index) const override;

protected:
    bool editorEvent(QEvent *event, QAbstractItemModel *model,
                     const QStyleOptionViewItem &option,
                     const QModelIndex &index) override;

private:
    QScopedPointer<QStyleOptionButton> m_buttonPtr;
};

#endif // BUTTONDELEGATE_H

 buttondelegate.cpp

#include "buttondelegate.h"
#include "student.h"

#include <QPainter>
#include <QApplication>
#include <QMouseEvent>
#include <QtWidgets>

ButtonDelegate::ButtonDelegate(QObject *parent)
    : QStyledItemDelegate(parent)
    , m_buttonPtr(new QStyleOptionButton)
{

}

void ButtonDelegate::paint(QPainter *painter,
                           const QStyleOptionViewItem &option,
                           const QModelIndex &index) const
{
    int w = qMin(option.rect.width(), option.rect.height()) / 10.0;
    m_buttonPtr->rect = option.rect.adjusted(w, w, -w, -w);
    m_buttonPtr->text = index.model()->data(index).toString();
    m_buttonPtr->state |= QStyle::State_Enabled;

    painter->save();

    if (option.state & QStyle::State_Selected) {
        painter->fillRect(option.rect, option.palette.highlight());
        painter->setBrush(option.palette.highlightedText());
    }

    QPushButton button;
    qApp->style()->drawControl(QStyle::CE_PushButton, m_buttonPtr.data(), painter, &button);

    painter->restore();
}

bool ButtonDelegate::editorEvent(QEvent *event,
                                 QAbstractItemModel *model,
                                 const QStyleOptionViewItem &option,
                                 const QModelIndex &index)
{
    int w = qMin(option.rect.width(), option.rect.height()) / 10.0;

    switch (event->type()) {
    case QEvent::MouseButtonPress:{
        QMouseEvent* mouseEvent =(QMouseEvent*)event;
        if (option.rect.adjusted(w, w, -w, -w).contains(mouseEvent->pos())) {
            m_buttonPtr->state |= QStyle::State_Sunken;
        }
    } break;
    case QEvent::MouseButtonRelease:{
        QMouseEvent* mouseEvent =(QMouseEvent*)event;
        if (option.rect.adjusted(w, w, -w, -w).contains(mouseEvent->pos())) {
            m_buttonPtr->state &= (~QStyle::State_Sunken);

            Student* stu = model->data(index, Qt::UserRole).value<Student*>();
            if(stu){
                QString details = tr("This Student id = %1, name = %2, age = %3, "
                                     "gender = %4, achievement = %5")
                                      .arg(stu->id)
                                      .arg(stu->name)
                                      .arg(stu->age)
                                      .arg(stu->gender)
                                      .arg(stu->achievement);
                QDialog dialog;
                QHBoxLayout *layout = new QHBoxLayout(&dialog);
                layout->addWidget(new QLabel(details, &dialog));
                dialog.exec();
            }
        }
    }
    break;
    default: break;
    }
    return true;
}
3、 进度条委托类

progressbardelegate.h

#ifndef PROGRESSBARDELEGATE_H
#define PROGRESSBARDELEGATE_H

#include <QStyledItemDelegate>

//进度条委托类
class ProgressBarDelegate : public QStyledItemDelegate
{
public:
    ProgressBarDelegate(QObject* parent = nullptr) : QStyledItemDelegate(parent) {}

    void paint(QPainter *painter,
               const QStyleOptionViewItem &option,
               const QModelIndex &index) const;
};

#endif // PROGRESSBARDELEGATE_H

 progressbardelegate.cpp

#include "progressbardelegate.h"

#include <QPainter>
#include <QtWidgets>

void ProgressBarDelegate::paint(QPainter *painter,
                                const QStyleOptionViewItem &option,
                                const QModelIndex &index) const
{
    QStyleOptionViewItem viewOption(option);
    initStyleOption(&viewOption, index);
    if (option.state.testFlag(QStyle::State_HasFocus))
        viewOption.state = viewOption.state ^ QStyle::State_HasFocus;

    QStyledItemDelegate::paint(painter, viewOption, index);

    int value = index.model()->data(index).toUInt();
    if (value < 0)
        value = 0;
    else if (value > 100)
        value = 100;
    int w = qMin(option.rect.width(), option.rect.height()) / 10.0;
    QStyleOptionProgressBar progressBarOption;
    progressBarOption.initFrom(option.widget);
    progressBarOption.rect = option.rect.adjusted(w, w, -w, -w);
    progressBarOption.minimum = 0;
    progressBarOption.maximum = 100;
    progressBarOption.textAlignment = Qt::AlignCenter;
    progressBarOption.textVisible = true;
    progressBarOption.progress = value;
    progressBarOption.text = tr("%1%").arg(progressBarOption.progress);

    painter->save();
    if (option.state & QStyle::State_Selected) {
        painter->fillRect(option.rect, option.palette.highlight());
        painter->setBrush(option.palette.highlightedText());
    }

    QProgressBar progressBar;
    qApp->style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter, &progressBar);

    painter->restore();
}
 4、排序代理

sortfilterproxymodel.h

#ifndef SORTFILTERPROXYMODEL_H
#define SORTFILTERPROXYMODEL_H

#include <QSortFilterProxyModel>

//排序代理
class SortFilterProxyModel : public QSortFilterProxyModel
{
public:
    SortFilterProxyModel(QObject *parent = nullptr)
        : QSortFilterProxyModel(parent) {}

protected:
    bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; //重定义排序规则
};

#endif // SORTFILTERPROXYMODEL_H

      sortfilterproxymodel.cpp  

#include "sortfilterproxymodel.h"

#include <QDateTime>

bool SortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
    QVariant leftData = sourceModel()->data(left);
    QVariant rightData = sourceModel()->data(right);

    if (leftData.userType() == QMetaType::QDateTime) {
        return leftData.toDateTime() < rightData.toDateTime();
    } else if(leftData.userType() == QMetaType::Int) {
        return leftData.toInt() > rightData.toInt();
    }
    QString leftString = leftData.toString();
    QString rightString = rightData.toString();
    return QString::localeAwareCompare(leftString, rightString) < 0;
}
5、学生数据表数据模型

 studenttablemodel.h

#ifndef STUDENTTABLEMODEL_H
#define STUDENTTABLEMODEL_H

#include <QAbstractTableModel>

struct Student;
class StuedentTableModel : public QAbstractTableModel
{
    Q_OBJECT
public:
    explicit StuedentTableModel(QObject *parent = nullptr): QAbstractTableModel(parent){}

    int rowCount(const QModelIndex & = QModelIndex()) const { return m_students.count(); }
    int columnCount(const QModelIndex & = QModelIndex()) const { return 7; }

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
    Qt::ItemFlags flags(const QModelIndex &index) const;
    void setStudents(const QList<Student *> &students);

private:
    QList<Student *> m_students;
};

#endif // STUDENTTABLEMODEL_H

 studenttablemodel.cpp

#include "studenttablemodel.h"
#include "student.h"

enum Property { ID, NAME, AGE, GENDER, ACHIEVEMENT, MENUBUTTON, PROCESS };

QVariant StuedentTableModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
        return false;

    int row = index.row();
    int col = index.column();

    Student *stu = m_students.at(row);
    switch (role) {
    case Qt::TextAlignmentRole: return Qt::AlignCenter;
    case Qt::CheckStateRole:
        switch (col) {
        case ID: return stu->checked;
        default: break;
        }
        break;
    case Qt::DisplayRole:
    case Qt::EditRole: { //双击为空需添加
        switch (col) {
        case ID: return stu->id;
        case NAME: return stu->name;
        case AGE: return stu->age;
        case GENDER: return stu->gender;
        case ACHIEVEMENT: return stu->achievement;
        case MENUBUTTON: return tr("Detail");
        case PROCESS: return stu->process;
        default: break;
        }
    case Qt::UserRole: {
        switch (col) {
        case MENUBUTTON: return QVariant::fromValue(stu);
        default: break;
        }
    }
    }
    default: break;
    }
    return QVariant();
}

bool StuedentTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    if (!index.isValid())
        return false;

    int row = index.row();
    int col = index.column();

    Student *stu = m_students[row];
    switch (role) {
    case Qt::CheckStateRole:
        switch (col) {
        case ID:
            stu->checked = !stu->checked;
            emit dataChanged(index, index);
            return true;
        default: break;
        }
        break;
    case Qt::EditRole:
        switch (col) {
        case ID: stu->id = value.toUInt(); break;
        case NAME: stu->name = value.toString(); break;
        case AGE: stu->age = value.toUInt(); break;
        case GENDER: stu->gender = value.toString(); break;
        case ACHIEVEMENT: stu->achievement = value.toUInt(); break;
        case PROCESS: stu->process = value.toUInt(); break;
        }
        emit dataChanged(index, index);
        return true;
    default: break;
    }
    return false;
}

QVariant StuedentTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
    const QStringList names = {tr("ID"),
                               tr("姓名"),
                               tr("年龄"),
                               tr("性别"),
                               tr("成绩"),
                               tr("详情"),
                               tr("进度")};
    if (section < 0 || section >= names.size())
        return QVariant();

    if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
        return names.at(section);
    return QVariant();
}

Qt::ItemFlags StuedentTableModel::flags(const QModelIndex &index) const
{
    Qt::ItemFlags flags = QAbstractTableModel::flags(index);
    flags |= Qt::ItemIsEditable;
    if (index.column() == ID)
        flags |= Qt::ItemIsUserCheckable;
    return flags;
}

void StuedentTableModel::setStudents(const QList<Student *> &students)
{
    beginResetModel(); //重置数据之前调用,会自动触发 modelAboutToBeReset 信号
    m_students = students;
    endResetModel();   //重置数据完成后调用,会自动触发 modelReset 信号
}
 6、学生数据表

stuedenttable.h

#ifndef STUDENTTABLE_H
#define STUDENTTABLE_H

#include <QAbstractTableModel>
#include <QStyledItemDelegate>
#include <QTableView>

struct Student;
class StuedentTableModel;
class StudentsTable : public QTableView
{
    Q_OBJECT
public:
    StudentsTable(QWidget *parent = nullptr);

    void setStudents(const QList<Student *> &students);

protected:
    void contextMenuEvent(QContextMenuEvent *event) override;

signals:
    void insertItem();
    void removeItem();

private:
    void initMenu();

    StuedentTableModel *m_stuModel;
    QMenu *m_menu;
};

#endif // STUDENTTABLE_H

 stuedenttable.cpp

#include "stuedenttable.h"
#include "buttondelegate.h"
#include "comboboxdelegate.h"
#include "progressbardelegate.h"
#include "sortfilterproxymodel.h"
#include "studenttablemodel.h"

#include <QtWidgets>

StudentsTable::StudentsTable(QWidget *parent)
    : QTableView(parent)
    , m_stuModel(new StuedentTableModel(this))
    , m_menu(new QMenu(this))
{
    setShowGrid(true);
    setWordWrap(false);
    setAlternatingRowColors(true);
    verticalHeader()->setVisible(false);
    verticalHeader()->setDefaultSectionSize(30);
    horizontalHeader()->setStretchLastSection(true);
    horizontalHeader()->setDefaultSectionSize(90);
    horizontalHeader()->setMinimumSectionSize(35);
    horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
    setSelectionBehavior(QAbstractItemView::SelectItems);
    setSelectionMode(QAbstractItemView::SingleSelection);
    setContextMenuPolicy(Qt::DefaultContextMenu);

    //设置委托
    setItemDelegateForColumn(3, new ComboBoxDelegate(this)); //下拉框
    setItemDelegateForColumn(5, new ButtonDelegate(this));  //按钮
    setItemDelegateForColumn(6, new ProgressBarDelegate(this)); //进度条

    //设置代理实现自定义排序
    setSortingEnabled(true);
    SortFilterProxyModel *sortModel = new SortFilterProxyModel(this);
    sortModel->setSourceModel(m_stuModel);
    setModel(sortModel);

    initMenu();
}

void StudentsTable::setStudents(const QList<Student *> &students)
{
    m_stuModel->setStudents(students);
}

void StudentsTable::contextMenuEvent(QContextMenuEvent *event)
{
    if (!currentIndex().isValid())
        return;
    m_menu->exec(mapToGlobal(event->pos()));
}

void StudentsTable::initMenu()
{
    m_menu->addAction(tr("insert"), this, &StudentsTable::insertItem);
    m_menu->addAction(tr("remove"), this, &StudentsTable::removeItem);
    m_menu->addAction(tr("rename"), this, [this] { edit(currentIndex().siblingAtColumn(0)); });
}

五、使用示例

以下是一个简单的示例代码,演示了如何在Qt中使用StudentsTable控件:

mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

struct Student;
class StudentsTable;
class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void onInsertItem();
    void onRemoveItem();

private:
    void init();
    void setupUI();
    StudentsTable *m_table;
    QList<Student *> m_students;
};
#endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h"
#include "student.h"
#include "studenttablemodel.h"
#include "stuedenttable.h"

#include <QtWidgets>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    setupUI();
    init();
    resize(800, 300);
}

MainWindow::~MainWindow()
{
    if (!m_students.isEmpty()) {
        qDeleteAll(m_students);
        m_students.clear();
    }
}

void MainWindow::onInsertItem()
{
    int row = m_table->currentIndex().row();
    Student *stu = new Student;
    stu->id = m_students.size();

    if (row < 0 || row >= m_students.size())
        m_students.append(stu);
    else
        m_students.insert(row, stu);

    m_table->setStudents(m_students);
}

void MainWindow::onRemoveItem()
{
    QModelIndex index = m_table->currentIndex();
    if (!index.isValid())
        return;
    int row = index.row();
    delete m_students.takeAt(row);
    m_table->setStudents(m_students);
}

void MainWindow::init()
{
    m_students.append(new Student{true, 0, "Jason", 15, "男", 66, 10});
    m_students.append(new Student{false, 1, "Lily", 13, "女", 85, 20});
    m_students.append(new Student{true, 2, "Odin", 16, "女", 76, 30});
    m_students.append(new Student{false, 3, "Willion", 12, "男", 89, 40});
    m_students.append(new Student{true, 4, "Nieo", 14, "男", 77, 50});
    m_table->setStudents(m_students);
    m_table->selectRow(m_students.size() - 1);
}

void MainWindow::setupUI()
{
    QPushButton *addBtn = new QPushButton(tr("增加"), this);
    QPushButton *removeBtn = new QPushButton(tr("删除"), this);
    m_table = new StudentsTable(this);

    QHBoxLayout *hLayout = new QHBoxLayout;
    hLayout->addStretch(1);
    hLayout->addWidget(addBtn);
    hLayout->addWidget(removeBtn);
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addLayout(hLayout);
    layout->addWidget(m_table);
    QFrame *frame = new QFrame(this);
    frame->setLayout(layout);
    setCentralWidget(frame);

    connect(m_table, &StudentsTable::insertItem, this, &MainWindow::onInsertItem);
    connect(m_table, &StudentsTable::removeItem, this, &MainWindow::onRemoveItem);
    connect(addBtn, &QPushButton::clicked, this, &MainWindow::onInsertItem);
    connect(removeBtn, &QPushButton::clicked, this, &MainWindow::onRemoveItem);
}

        到此本文基于QTableView的Model View Delegate使用方法就介绍到这了。

        总的来说,Qt的模型视图代理提供了一种灵活的方式来显示和编辑数据,在处理大量数据和复杂数据结构时特别有用。它将数据与界面分离,使得数据的表示和样式能够独立于数据本身进行修改。这种模式不仅提高了开发效率,还使得代码更加清晰和易于维护。

        谢谢您的阅读,希望本文能为您带来一些帮助和启发。如果您有任何问题或意见,请随时与我联系。祝您度过美好的一天!

六、源代码下载

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1987277.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

步进电机驱动调试问题

工作中&#xff0c;调试24-byj48步进电机遇到一个怪现象&#xff1a; 1. 偶现 2. 出现问题时其中一个马达反转无法驱动&#xff0c;正转正常。 排查思路&#xff1a; 1. 将两个电机交叉验证&#xff0c;发现始终跟M2接口有关。排除电机问题。 2. 检查电机IO口配置&#xf…

大数据项目——广告数仓之HTTP概述

目录 第一章、理解URL 1.1 客户端、服务器 1.1.1 服务器与服务 1.1.2 客户端 1.2 URL 1.3 查询参数 第一章、理解URL 1.1 客户端、服务器 1.1.1 服务器与服务 所谓服务器&#xff0c;其实就是一台24小时不关机的计算机&#xff0c;它也有自己的cpu、内存、网卡、…

Docker更新镜像源小记

Docker镜像源无法访问 进入docker目录 cd /etc/docker/编辑daemon.json文件&#xff0c;如果没有&#xff0c;则新建 {"registry-mirrors": ["https://dockerproxy.cn"] }收集一些镜像源地址&#xff0c;未测是否能用 “https://hub.uuuadc.top”,“htt…

Android 埋点信息分析——内存篇

源码基于&#xff1a;Android U 0. 前言 在前一篇《Android statsd 埋点简析》一文中简单剖析了Android 埋点采集、传输的框架&#xff0c;本文在其基础对埋点信息进行解析&#xff0c;来看下Android 中埋下的内存信息有哪些。 1. 通过代码剖析google 埋点内容 1.1 PROCESS_M…

网络安全之sql靶场(11-23)

sql靶场&#xff08;11-23&#xff09; 目录 第十一关&#xff08;post注入&#xff09; 第十二关 第十三关 第十四关 第十五关 第十六关 第十七关 第十八关 第十九关 第二十关 第二十一关 第二十二关 第二十三关 第十一关&#xff08;post注入&#xff09; 查看…

echart 制作 Grafana 面板之仪表盘

目录 前言准备工作实现代码代码详解总结相关阅读 前言 Grafana 是一个开源的可视化监控工具&#xff0c;支持多种数据源&#xff0c;并且可以创建丰富的仪表盘。ECharts 是一个强大的开源数据可视化库&#xff0c;通过结合这两者&#xff0c;我们可以创建自定义的仪表盘&…

GPIO输出控制之LED闪烁、LED流水灯以及蜂鸣器应用案例

系列文章目录 STM32之GPIO&#xff08;General Purpose Input/Output&#xff0c;通用型输入输出&#xff09; 文章目录 系列文章目录前言一、LED和蜂鸣器简介1.1 LED1.2 蜂鸣器1.3 面包板 二、LED硬件电路2.1 低电平驱动电路2.2 高电平驱动电路 三、蜂鸣器硬件电路3.1 PNP型三…

使用idea 把一个git分支的部分提交记录合并到另一个git分支上

一、需求 需要将A&#xff08;合并分支&#xff09;分支上的提交记录中的某一次&#xff08;或几次&#xff09;提交合并到B&#xff08;被合并分支&#xff09;分支上 说明&#xff1a;熟练使用idea可以直接看下图即可&#xff0c;若不熟悉可以根据下列步骤进行操作&#xf…

富士乐施5070-V打印机驱动安装

富士乐施5070-V打印机驱动安装 特指打印A3纸张需求&#xff0c;即驱动中能够选择纸张类型&#xff08;安装选择305df驱动只能打印A4类型&#xff09; 富士乐施打印机驱动下载网址&#xff1a; https://m3support-fb.fujifilm-fb.com.cn/driver_downloads/www/ 安装流程&…

C#自定义快捷操作键的实现 - 开源研究系列文章

这次想到应用程序的快捷方式使用的问题。 Windows已经提供了API函数能够对窗体的热键进行注册&#xff0c;然后就能够在窗体中使用这些注册的热键进行操作了。于是笔者就对这个操作进行了整理&#xff0c;将注册热键操作写成了帮助类&#xff0c;并且用此博文来记录这个使用DEM…

【教程】linux-ubuntu安装并配置docker

linux-ubuntu安装并配置docker 一、在线安装1.卸载历史版本情况一&#xff1a;如果之前是手动安装的话&#xff0c;一步一步卸载情况二&#xff1a;通过APT安装 2.使用APT安装&#xff08;推荐&#xff09;(1) 添加https软件包&#xff08;2&#xff09;在apt源中添加docker软件…

kubernets学习笔记——使用kubeadm构建kubernets集群及排错

使用kubeadm构建kubernets集群 一、准备工作1、repo源配置&#xff1a;阿里巴巴开源镜像源2、更新软件包并安装必要的系统工具3、同步时间4、禁用selinux5、禁用交换分区swap6、关闭防火墙 二、安装docker-ce、docker、cri-docker1、安装docker-ce2、开启内核转发&#xff0c;转…

【学习笔记】A2X通信的协议(四)- A2X PC5通信(二)

目录 6.1.2.4 A2X PC5单播链接释放程序 6.1.2.4.1 概述 6.1.2.4.2 发起UE启动A2X PC5单播链接释放程序 6.1.2.4.3 目标UE接受的A2X PC5单播链接释放程序 6.1.2.4.4 发起UE完成的A2X PC5单播链接释放程序 6.1.2.4.5 异常情况 6.1.2.4.5.1 发起UE的异常情况 6.1.2.5 A2X …

Linux——嵌入式学习——C++学习(1)

一、环境配置 由于之前安装过QT&#xff0c;所以直接连接网络之后&#xff0c;运行 运行之后检查安装版本 接着用qt的使用步骤 创建工程即可 三、 1、注释 单行注释&#xff1a;// 多行注释/* */ 2、auto 自动推导类型 2.1声明变量 使…

Linux小组件:makefile

引言&#xff1a; 我们在Windows下编程时使用vs这种集成开发环境&#xff0c;里面什么编译运行调试清理等等服务都被一连串打包好了。在Linux下怎么实现呢&#xff1f;使用我们伟大的makefile&#xff01; makefile是Linux下的一个工具&#xff0c;通过文本编辑器vim对文件内…

Linux内核编程(十一)设备模型

本文目录 一、知识点1. 设备模型2. sysfs 文件系统3. kobject、kset设备模型框架 二、kobject实验1. 创建kobject2. 释放kobject★示例 三、kset实验1. 创建kset2. 注销kset★示例 四、引用计数器1. 概念2. 为什么要引入引用计数器&#xff1f;3. 常用函数&#xff08;1&#x…

【Nuxt】发送请求

概述 以下方式只能在 setup / 生命周期钩子 里面使用。 useFetch 下面的 API / hooks 具体用法查看官网文档。 const BASE_URL http://codercba.com:9060/juanpi/api;// 1. $fetch server and client // $fetch(BASE_URL /homeInfo, { // method: GET // }).then(res &…

python爬虫04 | Reuqests库快速入门,干穿urllib

文章目录 Requests库简介提出请求响应内容二进制响应内容JSON 响应内容原始响应内容自定义标头更复杂的 POST 请求POST 多部分编码的文件响应状态代码响应标头Cookie重定向和历史记录超时错误和异常 Ending Requests库简介 什么是Requests库 Requests是一个简单易用的HTTP库&…

分享一个基于SpringBoot和Vue的闲置物品交易与物品租赁平台(源码、调试、LW、开题、PPT)

&#x1f495;&#x1f495;作者&#xff1a;计算机源码社 &#x1f495;&#x1f495;个人简介&#xff1a;本人 八年开发经验&#xff0c;擅长Java、Python、PHP、.NET、Node.js、Android、微信小程序、爬虫、大数据、机器学习等&#xff0c;大家有这一块的问题可以一起交流&…

人工智能计算机视觉先锋——OpenCv 的颜色检测

红色 在计算机的世界里&#xff0c;只有 0 或者1&#xff0c;如何让计算机认识颜色是计算机视觉工作者首先需要考虑的事情&#xff0c;我们知道整个世界的颜色虽然五彩缤纷&#xff0c;但是都是3种原色彩合成的&#xff08;R G B&#xff09;&#xff0c;有了&#xff08;R G …