QRegExpValidator编译错误

gohome520 2011-10-26 08:15:03
编译的时候提示错误,但实在不知道该怎么才能好使,请指教。
no matching function for call to 'QRegExpValidator::QRegExpValidator(QRegExp *&, IPLineEdit*const)'
candidates are:
QRegExpValidator::QRegExpValidator(const QRegExp&, QObject*)

class IPLineEdit : public QWidget
{
Q_OBJECT
public:
IPLineEdit(QWidget *parent = 0);

private:
QLineEdit *ipLineEdit;
QLabel *ipLabel;
QHBoxLayout *layout;
QRegExp *ipRegExp;
QRegExpValidator *ipRegExpValidator;
};

IPLineEdit::IPLineEdit(QWidget *parent)
{
ipLabel = new QLabel(tr("IP Address:"));
ipLineEdit = new QLineEdit;
ipLabel->setBuddy(ipLineEdit);

ipRegExp = new QRegExp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-4]|[01]?\\d\\d?)");
ipRegExpValidator = new QRegExpValidator(ipRegExp, this);
ipLineEdit->setValidator(ipRegExpValidator);
ipLineEdit->setInputMask("000.000.000.000;");

layout = new QHBoxLayout;
layout->addWidget(ipLabel);
layout->addWidget(ipLineEdit);

setLayout(layout);
}
...全文
874 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
gohome520 2011-10-26
  • 打赏
  • 举报
回复
终于弄清楚了,没看清错误提示,一直以为是第2个参数错误,实际是第1个参数有问题。
给大家看笑话了。。。

ipRegExp = new QRegExp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-4]|[01]?\\d\\d?)");
ipRegExpValidator = new QRegExpValidator(ipRegExp, this);

16,817

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧