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. QTextBrowser tutorial?
Forum Updated to NodeBB v4.3 + New Features

QTextBrowser tutorial?

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 2 Posters 4.3k Views 2 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.
  • P Offline
    P Offline
    Pippin
    wrote on last edited by
    #3

    Thank you @mrjj!

    @mrjj said:

    to catch when user click on such link use the anchorClicked signal
    ala
    connect(textBrowser, SIGNAL(anchorClicked(QUrl)), this, SLOT(MyOwnSlot(QUrl)));

    I am already using these shenanigans for real (Internet) Urls, but I'm not sure I know much about these issues. If we use the example I described in the OP, how would you make "Blue" or "Green" urls (ie. blue and underlined) ? How would you manage to determine which Url is clicked ? (Is it "Blue"? Is it "Green"? etc.)

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #4

      ++If we use the example I described in the OP, how would you make "Blue" or "Green" urls (ie. blue and underlined) ?
      Using the subset of html it supports.
      try with
      <font color="#0000FF">This will make your text blue.</font>

      ++How would you manage to determine which Url is clicked ? (Is it "Blue"? Is it "Green"? etc.)
      well you can string check the name. you get the url text so you must compared that as string.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Pippin
        wrote on last edited by
        #5
        <a href="foo">bar</a>
        

        Is foo or bar the url "name" or "text", as you called it?

        mrjjM 1 Reply Last reply
        0
        • P Pippin
          <a href="foo">bar</a>
          

          Is foo or bar the url "name" or "text", as you called it?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #6

          @Pippin
          well im not sure what will be in url.
          just try it
          i think foo.
          but just make function and qDebug() it and see

          P 1 Reply Last reply
          1
          • mrjjM mrjj

            @Pippin
            well im not sure what will be in url.
            just try it
            i think foo.
            but just make function and qDebug() it and see

            P Offline
            P Offline
            Pippin
            wrote on last edited by Pippin
            #7

            @mrjj Well if I put a quint32 as the url:

            foo->append("<a href=" + ref + ">" + q_string + "</a>");
            

            I never get ref back. When I run the slot:

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

            I print a character such as R or x but never something like 4144357970. Also, foo.toString().toStdString() gives the same result.

            mrjjM 1 Reply Last reply
            0
            • P Pippin

              @mrjj Well if I put a quint32 as the url:

              foo->append("<a href=" + ref + ">" + q_string + "</a>");
              

              I never get ref back. When I run the slot:

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

              I print a character such as R or x but never something like 4144357970. Also, foo.toString().toStdString() gives the same result.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #8

              hi
              can you try to use use
              foo->append("<a href=" + QString::number(ref) + ">" + q_string + "</a>");
              as I have shot my foot off many times with + int +

              P 1 Reply Last reply
              1
              • mrjjM mrjj

                hi
                can you try to use use
                foo->append("<a href=" + QString::number(ref) + ">" + q_string + "</a>");
                as I have shot my foot off many times with + int +

                P Offline
                P Offline
                Pippin
                wrote on last edited by
                #9

                @mrjj said:

                QString::number(ref)

                That was it! Thanks a bunch! :D

                mrjjM 1 Reply Last reply
                0
                • P Pippin

                  @mrjj said:

                  QString::number(ref)

                  That was it! Thanks a bunch! :D

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  @Pippin
                  super. :)
                  i used to do that often myself as it do not complains so I forgot :)

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    Pippin
                    wrote on last edited by
                    #11

                    Just wondering, is it normal that such a QUrl (that is, a QUrl constructed with a quint32 alone) returns true when QUrl::isValid() is called? Because that's what I get and I don't understand why 4144357970 is considered "valid."

                    mrjjM 1 Reply Last reply
                    0
                    • P Pippin

                      Just wondering, is it normal that such a QUrl (that is, a QUrl constructed with a quint32 alone) returns true when QUrl::isValid() is called? Because that's what I get and I don't understand why 4144357970 is considered "valid."

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by mrjj
                      #12

                      @Pippin said:

                      QUrl::isValid()

                      it says
                      "the URL is run through a conformance test. Every part of the URL must conform to the standard encoding rules of the URI standard for the URL to be reported as valid."

                      So I do agree that its strange if isValid is true..
                      so I guess 4144357970 is following the rules.

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        Pippin
                        wrote on last edited by
                        #13

                        So far any quint32 that I tried is considered a "valid" url. Well since this thread is marked as solved, I'll make a new one.

                        1 Reply Last reply
                        1

                        • Login

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