Results 1 to 5 of 5

Thread: linking in QWhatsThis

  1. #1
    Join Date
    Jun 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default linking in QWhatsThis

    I am working on a help system and we want to use links in the QWhatsThis object to connect with our online help viewer eg. setup like "Blah blah blah, for more information go here" with here being a link. My partner and I have been looking online for the past few days to find any tips or hints about how to do this and have found nothing of use. Does anyone know how to program the QWhatsThis to react to the link being clicked?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: linking in QWhatsThis

    From QWhatsThis docs:
    If the text is rich text and the user clicks on a link, the widget also receives a QWhatsThisClickedEvent with the link's reference as QWhatsThisClickedEvent::href(). If a QWhatsThisClickedEvent is handled (i.e. QWidget::event() returns true), the help window remains visible. Call QWhatsThis::hideText() to hide it explicitly.
    J-P Nurmi

  3. #3
    Join Date
    Jun 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: linking in QWhatsThis

    we saw that, but how do you actually implement dealing with the QWhatsThisEvent, we are both very new to Qt, our boss told us to start looking at this stuff a few days ago.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: linking in QWhatsThis

    Reimplement QWidget::event() and catch QEvent::WhatsThisClicked. It can be done more or less in this way:
    Qt Code:
    1. bool MyWidget::event(QEvent* event)
    2. {
    3. if (event->type() == QEvent::WhatsThisClicked)
    4. {
    5. QWhatsThisClickedEvent* clicked = static_cast<QWhatsThisClickedEvent*>(event);
    6. QDesktopServices::openUrl(clicked->href()); // do something with the link
    7. return true; // what's this remains open if true is returned
    8. }
    9. return QWidget::event(event); // call base class!
    10. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    mattc (21st July 2011)

  6. #5
    Join Date
    Jun 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: linking in QWhatsThis

    thanks, we really appreciate it, you have ended our many days of confusion.

Similar Threads

  1. Linking myLib with myApp
    By vermarajeev in forum Qt Programming
    Replies: 11
    Last Post: 20th February 2007, 13:51
  2. Statically Linking... everything
    By bpetty in forum Newbie
    Replies: 5
    Last Post: 26th October 2006, 17:43
  3. Replies: 3
    Last Post: 1st October 2006, 15:03
  4. import library linking
    By bruce1007 in forum Qt Programming
    Replies: 6
    Last Post: 19th May 2006, 10:27
  5. Replies: 4
    Last Post: 20th February 2006, 09:11

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.