Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Trouble getting history to work
Forum Updated to NodeBB v4.3 + New Features

Trouble getting history to work

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 836 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nicky j
    wrote on last edited by
    #1

    Hey everyone,

    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.
    void browseTab::addToHistory()
    {
    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().
    void browseTab::goToHistoryURL()
    {
    QAction *action = qobject_cast<QAction *>(sender());
    if (action)
    loadHistory(action->data().toString());
    }

    //sets the webView to the historyAction's url, called by goToHistoryURL().
    void browseTab::loadHistory(const QString &name)
    {
    webView->setUrl(QUrl(QString(name)));
    }

    @

    Code solution examples would be great!

    Thanks for your time!

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nicky j
      wrote on last edited by
      #2

      Any ideas? This is kinda my largest roadblock thus far

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nicky j
        wrote on last edited by
        #3

        how can I fix my code?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved