Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Trouble getting history to work
I am still having trouble getting the history on my web browser to work right.
I have 3 slots: addToHistory(), goToHistoryURL(), and loadHistory(). addToHistory is called when the webView loads a page, it creates a new QAction called historyAction which is added to a QMenu called historyMenu. This creates a list of history entries. When one of the historyActions is clicked, it calls goToHistoryURL(). goToHistoryURL() determines which historyAction has been clicked and calls loadURL(). loadURL() in turn sets the webView to the URL of whichever historyAction was clicked. The problem lies in when I click on one of the generated historyAction, it makes my application freeze and crash. How can I fix this? here is my code:
//adds a URL to history, called whenever webView finishes loading.
QString url = webView->url().toString();
QString historyEntry = url; QString title = webView->title(); QIcon icon = webView->icon(); QString text = tr("&%1").arg(title); historyAction = new QAction(this); historyAction->setText(text); historyAction->setData(historyEntry); historyAction->setIcon(webView->icon()); historyAction->setIconVisibleInMenu(true); HistoryMenu->addAction(historyAction); connect(historyAction, SIGNAL(triggered()), SLOT(goToHistoryURL()));
//determines which historyAction has been clicked, calls loadHistory().
QAction *action = qobject_cast<QAction *>(sender());
//sets the webView to the historyAction's url, called by goToHistoryURL().
void browseTab::loadHistory(const QString &name)
Code solution examples would be great!
Thanks for your time!
Any ideas? This is kinda my largest roadblock thus far
how can I fix my code?