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. Tab connected to lineEdit
Qt 6.11 is out! See what's new in the release blog

Tab connected to lineEdit

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.3k 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.
  • M Offline
    M Offline
    musti
    wrote on last edited by
    #1

    Hello !
    first I'm new in c++ and i'm trying to make a Web Browser as a project for my exam
    i added an action add tab and it work but when i add a new tab it's not connected to the lineEdit so i cannot add a new link and the line Edit its connected only to the first tab the original one and this is how i add new tab
    @void MainWindow::on_actionAdd_tab_triggered( )
    {

    QWebView *webView = new QWebView();
        ui->tabWidget->addTab(webView, " NewPage " );
    

    ui->webView->load("http://"+ui->lineEdit->text());

    }
    @
    thank you :)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Why does your UI have a webView, since you are adding them to the tabWidget ?

      What you can do for the line edit/ web view interaction is e.g. have a custom slot in MainWindow that will react on the line edit changes and call load on the current web view

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        musti
        wrote on last edited by
        #3

        thank you for responding :)
        so the " tab calling action " have to be : @
        void MainWindow::on_actionAdd_tab_triggered( )
        {

        QWebView *webView = new QWebView();
            ui->tabWidget->addTab(webView, " NewPage " );
        

        }@

        and in the mainwindows i have to add

        @
        void MainWindow::on_Go_clicked()
        {
        ui->webView->load("http://"+ui->lineEdit->text()); //

        }
        void MainWindow::on_lineEdit_returnPressed()
        {
        on_Go_clicked(); // lineEdit react on go botton pressed
        }
        @

        so i think the problem is how to make UI interface with the current tab ?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          ui->webView just point to the web view you added in designer, not the one you just added. This one must be retrieved from your tab widget

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            musti
            wrote on last edited by
            #5

            let me see if i get it
            from my add tab i have to return MyNewTab
            and then
            i have to do something like that :
            ui->MyNewTab ..........
            ? :)

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Not on your add tab method, in on_Go_clicked

              Have a look at QTabWidget's documentation to retrieve the current widget and qobject_cast to get the QWebView from that.

              Not everything you do includes using ui ;)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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