4144357970 is a "valid" QUrl?



  • Hello,

    this is a continuation of this thread that is now solved.

    The following line is run at the start of my program:

    QObject::connect(someQTextBrowser, SIGNAL(anchorClicked(const QUrl&)), this, SLOT(openUrl(const QUrl&)));
    

    Some time later, the following line is run:

    someQTextBrowser->append("<a href=" + QString::number(someQuint32) + ">" + someQString + "</a>");
    

    which creates and appends an url. When I click the url, the following slot is called:

    void MyInterface::openUrl(const QUrl& foo) const
    {
    	if (foo.isValid())
    		QDesktopServices::openUrl(foo);
    	else
    		std::cout << foo.url().toStdString() << std::endl;
    }
    

    Problem, no matter what quint32 I put in my urls, they are always considered "valid," which makes no sense to me. How did this happen?


  • Qt Champions 2016

    Hi
    I think by valid it means it do not contains any invalid letters
    https://url.spec.whatwg.org/#urls
    Not if it points to something real.

    So 4144357970 is just fine as it could be used as url.
    since all digits are allowed.



  • That would make sense, thanks @mrjj.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.