Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved]url recognition in qt
Forum Updated to NodeBB v4.3 + New Features

[solved]url recognition in qt

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    daljit97
    wrote on last edited by
    #1

    Hello, I'm working with the QUrl class. My problem is that I have to trigger an action if the recognize a specific url.
    Example:
    @void MyClass::trigger(QUrl*url)
    {
    if(url = "http://myurl.com)
    myapp.load()
    }@
    But It doesn't work.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      guziemic
      wrote on last edited by
      #2

      Hi,

      You cannot compare whole QUrl class to string, but you can use following comparison.
      If you would like to have just whole URL you could use "QUrl:toString":http://doc.qt.digia.com/stable/qurl.html#toString
      If you are interested only in domain you could use "QUrl:host":http://doc.qt.digia.com/stable/qurl.html#host

      Hope it help.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        adnan
        wrote on last edited by
        #3

        Your code is syntactically incorrect:
        @ void MyClass::trigger(QUrl*url)
        {
        if(url == "http://myurl.com")
        myapp.load();
        }
        @

        Besides, if you are trying to load any gui component, it is only possibly through mainwindow class. Non-gui classes can't display any gui components. You need to send a signal to main gui class to display any gui component.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          daljit97
          wrote on last edited by
          #4

          Thanks QUrl::toString works great!

          1 Reply Last reply
          0
          • E Offline
            E Offline
            elmigranto
            wrote on last edited by
            #5

            Comparing pointer with a string is just sick, bro (sintatically correct and can even return true though).

            1 Reply Last reply
            0
            • D Offline
              D Offline
              daljit97
              wrote on last edited by
              #6

              That was only an example to explain my problem, I know that a QUrl can't be a boolean.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved