Results 1 to 5 of 5

Thread: Getting title of website

  1. #1
    Join Date
    May 2013
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Getting title of website

    Hello.
    I'm writing my own web browser using WebKit built-in qt. I've created class PageX which contains QWebView object. I want to get the title of every visited website (content of <title> tags) and save it to some variable (QString, I guess). I've tried to use function title() from QWebView, but it holds an empty string by default and doesn't change its content when I open every next website. Please explain to me how can I deal with it.
    I'm using Qt 4.8.4 with QtCreator 2.6.1.
    Thanks in advance.

    PS Please reply in polish if you, dear helper, speak polish.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Getting title of website

    Hmm, I think that should work.

    Have you tried reading title() in a slot connected to the titleChanged() signal?

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Agent021 (18th May 2013)

  4. #3
    Join Date
    May 2013
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Getting title of website

    No, but to test, I've set displaying title() in LineEdit and I've run the browser. Nothing happened. The function still held an empty string. However, I've connected all this functions by signals and slots:

    pagex.h:
    Qt Code:
    1. signals:
    2. void title(QString);
    3.  
    4. private slots:
    5. void titleChanged(QString t);
    To copy to clipboard, switch view to plain text mode 

    pagex.cpp:
    Qt Code:
    1. connect(ui->web, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged(QString)));
    2. //...
    3. void pagex::titleChanged(QString t){
    4. emit title(t);
    5. }
    To copy to clipboard, switch view to plain text mode 

    And now it works, I can display the title that I've searched for. Thanks for your help.

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Getting title of website

    If you don't need the title in pagex you can do a "signal forwarding" connect
    Qt Code:
    1. connect(ui->web, SIGNAL(titleChanged(QString)), this, SIGNAL(title(QString)));
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  6. The following user says thank you to anda_skoa for this useful post:

    Agent021 (18th May 2013)

  7. #5
    Join Date
    May 2013
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Getting title of website

    O, thank you - I didn't know this possibility of connecting two signals. I actually need the title in other class so your advice helped me to save a lot of time.

Similar Threads

  1. Create a Website
    By Trader in forum Newbie
    Replies: 8
    Last Post: 10th July 2012, 07:27
  2. get favicon of website
    By pussbb in forum Qt Programming
    Replies: 4
    Last Post: 26th May 2011, 14:12
  3. Puzzle Example on Qt's website
    By yakuzan in forum Newbie
    Replies: 1
    Last Post: 27th May 2010, 05:43
  4. Replies: 0
    Last Post: 3rd June 2009, 04:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.