Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: QtWebKit-Tabs

  1. #1
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QtWebKit-Tabs

    Hello,
    I make simple browser but i have trouble. I want to make tabs but i don't know how. I try some things for example
    Qt Code:
    1. void MainWindow::AddTab(QUrl url)
    2. {
    3. view = new WebView(this);
    4. tabWidget->addTab(view,"");
    5. view->load(url);
    6. }
    To copy to clipboard, switch view to plain text mode 
    It's good but now SIGNALS and SLOTS don't know whitch view is SIGNAL and which SLOT.
    Thanks for answer
    SORRY FOR MY ENGLISH I'M NOT FROM USA OR ENGLAND

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QtWebKit-Tabs

    Quote Originally Posted by Viper666 View Post
    It's good but now SIGNALS and SLOTS don't know whitch view is SIGNAL and which SLOT.
    Thanks for answer
    What exactly is the question? Which signals and slots do you mean? How are they connected?
    SORRY FOR MY ENGLISH I'M NOT FROM USA OR ENGLAND
    I am not either

  3. #3
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtWebKit-Tabs

    Quote Originally Posted by ChrisW67 View Post
    What exactly is the question? Which signals and slots do you mean? How are they connected?
    The whole program is based on SIGNALS and SLOTS

    MainWindow.cpp - connections
    Qt Code:
    1. connect(webView->page->networkAccessManager(),SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
    2. this,SLOT(sslErrorHandler(QNetworkReply*,QList<QSslError>)));
    3. connect(urlEdit,SIGNAL(returnPressed()),this,SLOT(GoToUrl()));
    4. connect(backPage,SIGNAL(triggered()),webView,SLOT(back()));
    5. connect(nextPage,SIGNAL(triggered()),webView,SLOT(forward()));
    6. connect(urlEdit->refresh,SIGNAL(clicked()),webView,SLOT(reload()));
    7. connect(urlEdit->bookmarks,SIGNAL(clicked()),this,SLOT(AddBookmark()));
    8. connect(urlEdit->stop,SIGNAL(clicked()),webView,SLOT(stop()));
    9. connect(goHome,SIGNAL(triggered()),this,SLOT(GoHome()));
    10. connect(webView,SIGNAL(urlChanged(QUrl)),this,SLOT(urlChanged(QUrl)));
    11. connect(webView,SIGNAL(linkClicked(QUrl)),this,SLOT(linkClicked(QUrl)));
    12. connect(webView,SIGNAL(statusBarMessage(QString)),this,SLOT(statusBarMessage(QString)));
    13. connect(webView,SIGNAL(loadStarted()),this,SLOT(loadStarted()));
    14. connect(webView,SIGNAL(loadProgress(int)),this,SLOT(loadProgress(int)));
    15. connect(webView,SIGNAL(loadFinished(bool)),this,SLOT(loadFinished(bool)));
    16. connect(searchLine->search,SIGNAL(clicked()),this,SLOT(Search()));
    17. connect(searchLine,SIGNAL(returnPressed()),this,SLOT(Search()));
    To copy to clipboard, switch view to plain text mode 

    and only webView connections - back, forward, title changed - tabs name, url changed
    Qt Code:
    1. connect(webView,SIGNAL(urlChanged(QUrl)),this,SLOT(urlChanged(QUrl)));
    2. connect(webView,SIGNAL(linkClicked(QUrl)),this,SLOT(linkClicked(QUrl)));
    3. connect(webView,SIGNAL(statusBarMessage(QString)),this,SLOT(statusBarMessage(QString)));
    4. connect(webView,SIGNAL(loadStarted()),this,SLOT(loadStarted()));
    5. connect(webView,SIGNAL(loadProgress(int)),this,SLOT(loadProgress(int)));
    6. connect(webView,SIGNAL(loadFinished(bool)),this,SLOT(loadFinished(bool)));
    To copy to clipboard, switch view to plain text mode 

    And question: I have troubles with connection for example i have two tabs and now i click back and connection don't know which webview must go back

  4. #4
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: QtWebKit-Tabs

    Do you understand me what i mean?

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QtWebKit-Tabs

    Do you understand me what i mean?
    Yes, but I do need to sleep from time to time.

    Clearly if you connect the back button to only one QWebView then only one QWebView can be affected. Connect your back button to a slot of your own that looks up the current tab widget (QTabWidget::currentWidget()), qobject_cast it to QWebView*, and call back() on that widget. The same logic goes for the forward button etc.

  6. #6
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtWebKit-Tabs

    I start working with it.
    Thanks for help and
    Quote Originally Posted by ChrisW67 View Post

    I am not either
    I'm not from english speaks country and I learnt speak English only in the school only 3 years (It long time, but in school don't learn speak a lot and so I'm happy that you understand me )
    I'm going to try it but one thing isn't for me clearly in mainwindow.cpp i let any connections and i make my own slot for http://doc.qt.nokia.com/4.7-snapshot...currentChanged and here i can give
    Qt Code:
    1. widget = tabWidget->currentWidget();
    2. view = qobject_cast<WebView*>(widget);//i wrote this from head. Here can be any errors
    3. //and here i give here view's connections
    To copy to clipboard, switch view to plain text mode 
    Right???
    or It will working when all connections will be in constructor ??
    Last edited by Viper666; 3rd July 2012 at 12:48.

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QtWebKit-Tabs

    Your English is quite understandable.

    In your main window constructor you create your UI (back, forward buttons etc.) and connect the buttons to slots defined in the main window class. In the slot you use the code you started above and then you directly call the back() or forward() functions of the web view. There are no signal-slot connections to the web view for navigation. Something like;
    Qt Code:
    1. MainWindow::MainWindow(QWidget *p) : QWidget(p)
    2. {
    3. setupUi();
    4.  
    5. connect(ui->backButton, SIGNAL(clicked()), SLOT(doBack()));
    6. connect(ui->forwardButton, SIGNAL(clicked()), SLOT(doForward()));
    7. ...
    8. }
    9.  
    10.  
    11. void MainWindow::doBack()
    12. {
    13. QWidget *widget = tabWidget->currentWidget();
    14. QWebView *view = qobject_cast<QWebView*>(widget);
    15. if (view) // in case you have a tab that is not a QWebView
    16. view->back();
    17. }
    To copy to clipboard, switch view to plain text mode 

  8. The following user says thank you to ChrisW67 for this useful post:

    Viper666 (4th July 2012)

  9. #8
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtWebKit-Tabs

    Quote Originally Posted by ChrisW67 View Post
    Your English is quite understandable.
    So I'm glad.
    And thanks for all answers they were very helpful.
    Last edited by Viper666; 4th July 2012 at 10:55.

  10. #9
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtWebKit-Tabs

    oh I started work with it and now go back and so work fine but for example TitleChanged don't work- only first webview(default webview- in constructor) emit signal second webview doesn't work, it doesn't emit signal and one thing when i use tabwidget first 3 actions don't react

  11. #10
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QtWebKit-Tabs

    Quote Originally Posted by Viper666 View Post
    oh I started work with it and now go back and so work fine but for example TitleChanged don't work- only first webview(default webview- in constructor) emit signal second webview doesn't work, it doesn't emit signal
    Sure it does; when the widget's displayed web page title changes. What have you connected it to? What are you doing to update the window title when you switch between tabs? I could guess all day. How about describing, or better showing, the code you have used and explaining what you expected it to do, what it is doing, and why you think that might be.

    and one thing when i use tabwidget first 3 actions don't react
    No idea what you are talking about.

  12. #11
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtWebKit-Tabs

    I can this make throw tabwidget signal currentchanged and make my own slot bu how i can reload only title of page??? i will send code but now i'm not at my PC.
    And i don't now when i make tab widget like this
    Qt Code:
    1. view = new WebView(this);
    2. tab = new QTabWidget(view);
    3. ui->toolbar->addAction(goBack);....
    To copy to clipboard, switch view to plain text mode 
    first 3 actions don't react(no action but area where are they don't react)
    my constructor when it don't work
    Qt Code:
    1. urlLine = new UrlLine(this);
    2. searchLine = new SearchLine(this);
    3.  
    4. goHome = new QAction(QIcon(":/Icons/Home.png"),"http://google.sk",this);
    5. goBack = new QAction(QIcon(":/Icons/Back.png"),"Back",this);
    6. goForward = new QAction(QIcon(":/Icons/Forward.png"),"Forward",this);
    7. downloads = new QAction(QIcon(":/Icons/Downloads.png"),"Downloads",this);
    8. spacer = new QWidget(this);
    9. spacer->setMaximumSize(5,5);
    10. spacer->setMinimumSize(5,5);
    11. currentWidget = new QWidget(this);
    12.  
    13.  
    14. ui->toolBar->addAction(goBack);
    15. ui->toolBar->addAction(goForward);
    16. ui->toolBar->addSeparator();
    17. ui->toolBar->addWidget(urlLine);
    18. ui->toolBar->addWidget(spacer);
    19. ui->toolBar->addWidget(searchLine);
    20. ui->toolBar->addAction(goHome);
    21.  
    22. Web = new WebView(this);
    23. tabWidget = new QTabWidget(Web);
    24. setCentralWidget(tabWidget);
    25. tabWidget->insertTab(TabIndex,Web,"google.com");
    26.  
    27. Web->load(QUrl("http://google.com"));
    To copy to clipboard, switch view to plain text mode 
    Last edited by Viper666; 19th July 2012 at 12:16.

  13. #12
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtWebKit-Tabs

    if you don't understand me say i try again it

  14. #13
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QtWebKit-Tabs

    When you add a new tab connect the QWebView::titleChanged() signal to a common slot that either changes the relevant tab text, main window title bar text, or both. You can set the text on the tab with QTabWidget::setTabText() or in the main window title bar with QWidget::setWindowTitle(). You can determine which tab corresponds to the QWebView sender by using QTabWidget::indexOf().

  15. The following user says thank you to ChrisW67 for this useful post:

    Viper666 (21st July 2012)

  16. #14
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtWebKit-Tabs

    i try it but is my function correct???
    Qt Code:
    1. void MainWindow::OpenInNewTab(QUrl url)
    2. {
    3. Web = new WebView(this);
    4. TabIndex++;
    5. tabWidget->insertTab(TabIndex,Web,"(untitled)");
    6. tabWidget->setCurrentIndex(TabIndex);
    7. QMessageBox::information(this,"as",url.toString());
    8. Web->load(url);
    9. //and here i add connect
    10. }
    To copy to clipboard, switch view to plain text mode 

  17. #15
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtWebKit-Tabs

    it work very fine thanks and sorry if i wrote some stupid things i'm 14 years old and i'm fighting with my english and my logic
    Last edited by Viper666; 21st July 2012 at 14:42.

  18. #16
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtWebKit-Tabs

    and one thing for example http://www.google.com/imgres?num=10&...0&tx=113&ty=32 show page but the image isn't show like in firefox show only pages with images no only image

  19. #17
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtWebKit-Tabs

    someone told me that i can make tabs with threads it is good idea or bad idea

  20. #18
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QtWebKit-Tabs

    You do not need threads to make a basic tabbed browser and they will only cause you further heartache.

    I did not understand what you were talking about regarding images.

  21. #19
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtWebKit-Tabs

    When you browse images on google and click on it show image and website in background in my browser show only the websites in background imaga don't show

  22. #20
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtWebKit-Tabs

    you said it ok i made some test with thread and i want in ~MainWindow stop thread so i make static funcion (i will start thread in my TabWidget class)
    Qt Code:
    1. static void DestroyThread()
    2. {
    3. exit(0);
    4. }
    To copy to clipboard, switch view to plain text mode 
    but now i have 1 error i don't know what i should do error = cannot call member function 'void QThread::exit(int)' without object. It is good idea. Delete it all threads? or have you better idea?
    Thanks

Similar Threads

  1. QML tabs
    By user2704 in forum Newbie
    Replies: 0
    Last Post: 25th May 2012, 18:03
  2. Replies: 0
    Last Post: 29th February 2012, 09:48
  3. Dockable Tabs
    By lucastonon in forum Newbie
    Replies: 2
    Last Post: 23rd September 2011, 07:54
  4. how to interact with tabs in qt
    By rahulgogoi in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2011, 12:24
  5. Tabs communication
    By therealjag in forum Qt Programming
    Replies: 6
    Last Post: 18th April 2006, 18:19

Tags for this Thread

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.