Intro to model view programming

本文介绍了一个使用Qt框架实现的应用程序案例,该程序通过QPushButton触发不同功能,包括向QStringListModel添加、插入和删除条目。文章展示了如何初始化一个包含预设项目的列表,并演示了如何将同一个模型同时应用到QListView和QComboBox中。
#ifndef MODVIEW_H
#define MODVIEW_H

#include <QMainWindow>
#include <QtCore>

namespace Ui {
class ModView;
}

class ModView : public QMainWindow
{
    Q_OBJECT

public:
    explicit ModView(QWidget *parent = 0);
    ~ModView();

private slots:
    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_clicked();

private:
    Ui::ModView *ui;
    QStringListModel *model;
};

#endif // MODVIEW_H


cpp=====

#include "modview.h"
#include "ui_modview.h"
ModView::ModView(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ModView)
{
    ui->setupUi(this);
    model = new QStringListModel(this);
    QStringList list;
    list << "cats" << "dogs" << "birds";
    model->setStringList(list);
    ui->listView->setModel(model);
    ui->comboBox->setModel(model);
    ui->listView->setEditTriggers(QAbstractItemView::AnyKeyPressed | QAbstractItemView::DoubleClicked);
}
ModView::~ModView()
{
    delete ui;
}
void ModView::on_pushButton_2_clicked()
{
    //add
    int row = model->rowCount();
    model->insertRows(row,1);
    QModelIndex index = model->index(row);
    ui->listView->setCurrentIndex(index);
    ui->listView->edit(index);
}
void ModView::on_pushButton_3_clicked()
{
    //insert
    int row = ui->listView->currentIndex().row();
    model->insertRows(row,1);
    QModelIndex index = model->index(row);
    ui->listView->setCurrentIndex(index);
    ui->listView->edit(index);
}
void ModView::on_pushButton_clicked()
{
    //delete
    model->removeRows(ui->listView->currentIndex().row(),1);
}


                
### picoCTF Burp Suite 题目 intro to burp 解题思路 在 picoCTF 比赛中,Burp Suite 是一个常用的工具,尤其在 Web 渗透测试相关的题目中。以下是对 `intro to burp` 题目的解题思路的详细分析。 #### 1. 理解题目背景 `intro to burp` 题目通常要求参赛者熟悉 Burp Suite 的基本功能,例如拦截 HTTP 请求、修改请求参数以及观察响应内容。Burp Suite 是一款功能强大的 Web 渗透测试工具,能够帮助用户捕获和分析 HTTP/HTTPS 流量[^1]。 #### 2. 配置 Burp Suite 首先需要确保 Burp Suite 已正确配置,并且浏览器流量被代理到 Burp Suite 上。以下是具体步骤: - 启动 Burp Suite 并打开 Proxy 模块。 - 配置浏览器代理设置为 `127.0.0.1:8080`(默认端口)。 - 在浏览器中访问目标网站,确保所有流量通过 Burp Suite 捕获。 #### 3. 捕获并分析 HTTP 请求 在 Burp Suite 的 Proxy 模块中,可以查看和修改所有通过代理的 HTTP 请求和响应。对于 `intro to burp` 题目,通常需要完成以下操作: - 捕获目标网站的登录请求或表单提交请求。 - 修改请求中的参数值,例如用户名或密码字段。 - 观察服务器返回的响应,寻找可能的漏洞或提示信息。 #### 4. 利用 Repeater 模块 Burp Suite 的 Repeater 模块允许用户重新发送已捕获的请求,并进行动态修改。对于某些题目,可能需要使用 Repeater 来多次尝试不同的输入值。例如: ```python POST /login HTTP/1.1 Host: target-site.com Content-Type: application/x-www-form-urlencoded username=admin&password=test ``` 通过修改 `username` 和 `password` 的值,可以尝试绕过简单的身份验证机制[^1]。 #### 5. 查找 Flag 在许多 picoCTF 题目中,Flag 通常以特定格式存储在页面源代码或服务器响应中。例如,`<flag>your_flag_here</flag>` 或直接嵌入文本中。利用 Burp Suite 的搜索功能,可以在捕获的响应中快速定位 Flag。 --- ### 示例代码:修改 HTTP 请求 以下是一个使用 Burp Suite 修改 HTTP 请求的示例: ```python # 原始请求 POST /login HTTP/1.1 Host: target-site.com Content-Type: application/x-www-form-urlencoded username=user&password=pass # 修改后的请求 POST /login HTTP/1.1 Host: target-site.com Content-Type: application/x-www-form-urlencoded username=admin&password=test ``` --- ### 注意事项 - 确保在合法环境中使用 Burp Suite,避免对未经授权的目标进行攻击[^2]。 - 如果题目涉及更复杂的漏洞(如 SQL 注入或 XSS),需要结合相关知识进行分析和利用[^3]。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值