Open html page



  • hello i have a page called test_page.html like this:
    @ <table>
    <b>Inserisci la password</b>
    <form name="form_a" method="POST" action="http://www.test_site/riverside.php">
    <input type="passwd" name="password" value="myvalue"></input>;
    <input type="submit" name="Entra" value="entra"></input>;
    </form>
    </table>

    </div>
    [removed]
    document.form_a.submit();
    [removed]@
    i need to open in in a web browser how can i use?
    Thanks

    Luca


  • Moderators

    You could start a web browser in QProcess. If you like to have an external browser.

    Within Qt how about "QWebView":http://doc.qt.nokia.com/4.7/qwebview.html#QWebView ?



  • Hello i have write this c++:
    @#include "widget.h"
    #include "ui_widget.h"
    #include <QWebView>

    Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
    {
    ui->setupUi(this);
    connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(apro_pagina()));
    connect(&vista,SIGNAL(loadStarted()),this,SLOT(inizio_caricamento()));
    connect(&vista,SIGNAL(loadProgress(int)),this,SLOT(stato(int)));
    connect(&vista,SIGNAL(loadFinished(bool)),this,SLOT(finito(bool)));

    }

    Widget::~Widget()
    {
    delete ui;
    }

    void Widget::apro_pagina(){
    vista.setHtml("test_page.html");
    }

    void Widget::inizio_caricamento(){
    ui->label->setText("Inizio Caricamento");
    }

    void Widget::stato(int perc){
    ui->label->setText(QString::number(perc));
    }

    void Widget::finito(bool vero){
    ui->label->setText("Caricamento Finito");
    vista.show();
    }@

    But when the widget is open i see only a white page with written inside test_page.html

    What is wrong

    Thanks
    Luca



  • vista.setHtml() should have the HTML as argument, not the path to a file!

    For a file, you should call load() with a QUrl as parameter (denoting the complete path to your html file).



  • Thanks for your time, now works

    Luca



  • QDesktopServices::openUrl(QUrl("file:///C:/Documents and Settings/All Users/Desktop", QUrl::TolerantMode));


  • Moderators

    I guess you have checked already that the signals are triggered and that you are arriving the appropriate slots.

    Have a look to the "previewer example":http://doc.qt.nokia.com/4.7/webkit-previewer.html
    I guess your problem is
    @
    void Widget::apro_pagina(){
    vista.setHtml("test_page.html");
    }
    @
    I would have passed a string containing the web page content, but not the name of file with the content.
    If you debug through the example, you should see what you have to pass.



  • Hi,

    I see that the issue is already solved thanks to Volker but I want to advertise two very simple code snippets related to the topic that I have added lately to the wiki :)
    "Open Web Page in QWebView":http://developer.qt.nokia.com/wiki/Open_Web_Page_in_QWebView
    "How to launch Web Browser":http://developer.qt.nokia.com/wiki/How_to_Launch_Web_Browser

    Cheers,
    Leon


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.