Results 1 to 6 of 6

Thread: Application crashes on click of a QLabel that is set to open URL in browser

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Application crashes on click of a QLabel that is set to open URL in browser

    I have a pop-up widget that shows on entering a specific cell of QTableWidget. And I'm closing the pop-up window on leave event.
    The pop-up widget has got some QLabels, which are set as URLs. When I click on a hyperlink(QLabel), the link is opened in my browser. And when I click on another url Qlabel, the link is opened, but my application crashes immediately.

    One observation is if the mouse is taken out of the pop-up window, before it takes time to open the link in the browser, the application doesn't crash.

    Qt Code:
    1. //cpopupwindow.h
    2. // this closes the window when the mouse is out of widget
    3. protected:
    4. bool eventFilter(QObject * object, QEvent * event)
    5. {
    6. if(event->type() == QEvent::Leave)
    7. {
    8. if(isVisible())
    9. {
    10. while(!cveReferences.isEmpty())
    11. {
    12. delete cveReferences.takeFirst();
    13. }
    14. this->close();
    15. }
    16. }
    17.  
    18. return QWidget::eventFilter(object, event);
    19. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // in cpopupwindow.cpp
    2. this->installEventFilter(this); //in ctor
    3.  
    4. // this is a public function which displays the content and is called in tablewidget class on cellEnter()
    5. void CPopupWindow::someFunction()
    6. {
    7. // This is how I add the text to QLabels
    8. if("CVE" == repoType)
    9. {
    10. cceReference_table->setVisible(false);
    11. for(int i = 0; i < lst.count(); i++)
    12. {
    13. cveReferences.append(new QLabel());
    14. cveReferences.at(i)->setText("<a href=\"" + references.value(lst.at(i)) + "\">" +
    15. lst.at(i) + "</a>");
    16. cveReferences.at(i)->setTextFormat(Qt::RichText);
    17. cveReferences.at(i)->setTextInteractionFlags(Qt::TextBrowserInteraction);
    18. cveReferences.at(i)->setOpenExternalLinks(true);
    19. vLyt->addWidget(cveReferences.at(i));
    20. }
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 

    Everything is fine until second click of the URL. On second click, if the mouse is not taken out of pop-up widget, then the whole application crashes.
    Kindly help me with this. Thank you.
    Last edited by rawfool; 16th June 2013 at 22:15.

Similar Threads

  1. Hyperlink text in QLabel to open web browser
    By qt_developer in forum Qt Programming
    Replies: 7
    Last Post: 4th October 2018, 06:47
  2. Replies: 0
    Last Post: 8th May 2012, 13:29
  3. Replies: 0
    Last Post: 17th March 2011, 03:17
  4. How to open a browser ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 4th December 2006, 18:21
  5. open a browser
    By npc in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 10:23

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.