#include "mainwidget.h"
#include<QPushButton>
mainwidget::mainwidget(QWidget *parent)
: QWidget(parent)
{
//初始化按钮
b1 = new QPushButton("change title",this);
b1->move(100,100);
b2 = new QPushButton("close",this);
b2->move(200,200);
this->setFixedSize(400,400);
this->setWindowTitle("congratolation");
this->setWindowIcon(QIcon("C:\\Users\\Point\\Desktop\\timg.jpg"));
connect(b2,&QPushButton::clicked,this,&mainwidget::close);
connect(b1,&QPushButton::clicked,this,&mainwidget::setWindowTitle("diffrent");
}
mainwidget::~mainwidget()
{
}
b1按钮提示错误:
C:\Users\Point\signalandslot\mainwidget.cpp:18: error: lvalue required as unary '&' operand
connect(b1,&QPushButton::clicked,this,&mainwidget::setWindowTitle("diffrent");
问题出现,是不是因为click为布尔值,widget的titlename是string,就不能连接上?所以如果要改成按钮
^