画板如图所示,想实现线宽变化后,画图工具的线宽可以变化。主窗口是editpicture,画板为paintwidget,算是两个类之间传递数据。

qt 简易画板换线宽


想用spinbox的valuechange信号,在主窗口中添加connect,area为paintwidget的对象
editpicture.cpp
//初始宽度设为一,用于画图
ui->spinBox_2->setValue(1);
connect(ui->spinBox_2,SIGNAL(valueChanged(int)), area,SLOT(getPenwidth(int)));
//在paintwidget中声明penwidth,并添加槽函数及定义
paintwidget.h
private:
    int penwidth = 1;//初始宽度设为一,用于画图
public slots:
    void getPenwidth(int a){ penwidth = a; }
这样就可以了

相关文章:

  • 2021-12-04
  • 2021-10-08
  • 2022-12-23
  • 2022-01-05
  • 2021-11-16
  • 2022-01-08
  • 2021-08-04
  • 2021-06-20
猜你喜欢
  • 2021-06-18
  • 2021-07-10
  • 2021-05-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案