即使我现在一直在使用C ++,我对Qt也很陌生。我有这个程序,我必须检查URL是否有效以及它是否有效,将行编辑的边框更改为红色。
QRegularExpression url("/(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/igm");
QRegularExpressionValidator validator(url , 0);
int pos = 0;
QString input_url;
input_url = ui->URLfield->text();
if ( validator.validate(input_url , pos) == QValidator::Invalid || validator.validate(input_url , pos) == QValidator::Invalid)
{
ui->URLfield->setStyleSheet( " QLineEdit{border:5px solid #ff0000 ; \\n border-radius: 28px; \\n font-family: Arial; \\n color: #3498db; \\n font-size: 20px; \\n padding: 10px 20px 10px 20px; \\n text-decoration: none;" );
}
请帮忙!我对Qt不清楚的文档感到非常沮丧。