Results 1 to 6 of 6

Thread: restrict QLabel Internet assess

  1. #1
    Join Date
    Apr 2018
    Posts
    3
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default restrict QLabel Internet assess

    Hi. Any one know how to prevent QLabel dig into internet when loading html? We load small compatible with QLabel html files. But if user by mistake try to load file saved from internet, it take very long time, and program begin lagging. But when internet assess is disabled - any file loading quickly with no lag.
    Is it possible to restrict QLabel loading external links in html?

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: restrict QLabel Internet assess

    You could connect to signal linkActivated(), and do the internet available check and do required stuff.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Apr 2018
    Posts
    3
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: restrict QLabel Internet assess

    Quote Originally Posted by Santosh Reddy View Post
    You could connect to signal linkActivated(), and do the internet available check and do required stuff.
    Hi, thanks for your answer, but how "link user interaction signal" related to my question? I need to prevent internal QLabel internet access, while it loading initial html file - before user see any text on screen.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: restrict QLabel Internet assess

    You can (should always) sanitise the user input before giving it to QLabel. The simplest approach might be to start with: If the text provided contains "http://" or "https://" then reject it. If you need to load local resources from an intranet then: If the text provided contains "http://site/" or "https://site/" where site is not one of yours then reject it.

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

    Kirsan (25th April 2018)

  6. #5
    Join Date
    Apr 2018
    Posts
    3
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: restrict QLabel Internet assess

    Thank you, I came to about the same decision. But sadly, "http://" or "https://" can occur in comment sections, for example:
    <!--HTML generated by ..., http://...-->
    So it's not the simple regexp search...
    Last edited by Kirsan; 25th April 2018 at 09:06.

  7. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: restrict QLabel Internet assess

    In <a> or <img> elements the URLs will be href="..." or src="http://..." so look for the attribute name as well would help.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

Similar Threads

  1. Restrict Boundary for QGraphicsPolygonItem
    By sean.reynolds in forum Newbie
    Replies: 1
    Last Post: 10th April 2011, 12:07
  2. Replies: 1
    Last Post: 29th September 2009, 19:44
  3. QTableView restrict ScrollArea
    By hoshy in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2009, 08:54
  4. Can we restrict the movement of a Qt Window?
    By Frank J. Lhota in forum Qt Programming
    Replies: 4
    Last Post: 21st October 2008, 20:34
  5. How to restrict autodelete in Qt?
    By vql in forum Qt Programming
    Replies: 1
    Last Post: 23rd March 2008, 11:28

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.