[solved]How to add a link to next page?

  • I am right now working on a project which has a login page. I wanted to make the "can't access" as a hyperlink look not a push button not anything else. Can anyone please help me?

  • Consider using "QTextBrowser":http://doc.qt.nokia.com/4.7/qtextbrowser.html as it inherits QTextEdit and provides a rich text browser with hypertext navigation.

  • Can you plz show me a example code. So that It could be a bit more clear :)

  • What's the "can't access" thing you're talking about?
    You can always add a QLabel with some rich text and catch the linkActivate signal.

  • I am doing a project. I had created a login page. Which has some fields like the following:

    @Username(QLabel) :(QTextEdit)
    Password(QLabel) :

    Login(QPushButton) Quit(QPushButton)

    Can't access my account(QPushButton)
    Instead of making that "Can't access my account" a QPushButton, I want it to look like a hyperlink, when clicked on that area, It will go to Can't access page that I have created.

  • As I said:

    bq. You can always add a QLabel with some rich text and catch the linkActivate signal.

  • I guess you want to make the button look just like a link.In that case, You can set "flat":http://doc.qt.nokia.com/latest/qpushbutton.html#flat-prop property using the method setFlat(bool);

    You can change the colour and give an underline,by setting the style sheet.

    EDIT : May be its a good idea to change the thread title ,something like "Appear a button as hyperlink" etc..

  • As peppe said:

    //in constructor
    QLabel* noAccessLabel = new QLabel(this);
    //put the label in the appropriate layout

    noAccessLabel->setText(tr("<html><a >I can't access my account</a></html>/"));

    connect(noAccessLabel, SIGNAL(linkActivated(QString)), this, SLOT(forgotPasswordActivated(QString)));


    LoginForm::forgotPasswordActivated(const QString& url)
    if (url == "app://forgotPassword") {
    //do your magic here

    line 5 of the code should have a valid, nicely escaped URL in the < a > tag, but it seems the forum is messing that up (perhaps to prevent spam?)

  • @
    <a href ='developer.qt.nokia.com/forums/viewthread/9196/'>I can't access my account</a> </html>"));

  • Thanks a lot to you all. It was a great help.. Truely very much thanks. :)

Log in to reply

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