点击qt中的“按钮”后如何画线

时间:2017-07-13 12:56:04

标签: qt signals-slots paintevent

example:    select FORMAT(dateadd(ww,datediff(ww,0,getdate()),0),'dd MMM yyyy')--if you are using SQL 2012+

answer:  
SELECT COUNT(*) AS 'Number of Items', FORMAT(dateadd(ww,datediff(ww,0,date_column),0),'dd MMM yyyy')
FROM table
where DATEPART(Year, Date) = '2017' and DATEPART(MONTH, Date) = 5
group by DATEPART(WEEK, Date)

点击后,设置绘图点,标签显示为预期;

    #include "widget.h"
    #include "ui_widget.h"
    #include <ostream>

    Widget::Widget(QWidget *parent) :
        QWidget(parent),
        ui(new Ui::Widget)
    {
        ui->setupUi(this);
        p1 = new QPoint;
        p2 = new QPoint;

        connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(on_pushButton_clicked()));
    }

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{

    Widget *ff = new Widget(this);
    ff->curveProcess();

}
使用QPoint * p1在头文件中声明了p1和p2;     QPoint * p2; void virtual paintEvent(QPaintEvent *);

void Widget::curveProcess() {

        QLabel  label;
        label.setText("hahaha");
        label.show();
        p1->setX(0);
        p1->setY(0);
        p2->setX(100);
        p2->setY(100);
        update();

    }

点击按钮后,标签显示,我认为这意味着插槽工作正常,但我根本没有线。我是Qt的新人,真诚地感谢

0 个答案:

没有答案