Tab connected to lineEdit
-
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 :) -
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
-
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 ?
-
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
-
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 ..........
? :) -
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 ;)