Click URL



  • Hi, I was trying to click URL in the QTextEdit. But it is not possible, i.e no signals can be emitted when we try to click the URL. But it is possible in the TextBrowser.

    Is there any breakthrough for this ? Like subclass a Widget or can i* inherit some properties or MouseEvents* of other widget into the TextEdit.??



  • This functionality is added by QTextBrowser, which inherits QTextEdit. I guess you are after an editor where you can edit the text as well as use hyperlinks?

    You can extend QTextBrowser to support hyperlinks. You just have to implement the handling yourself. However, QTextBrowser has some methods to help you with that. Look at anchorAt(), for instance. If you handle the mouseClick event, you can use this method to see if there is an anchor under at the position you're at. If so, you can use that anchor.

    I am not sure it would be possible to submit QTextBrowser into being editable again.



  • Yep. Subclass, take the cursor at the mouse click position (QTextEdit::cursorForPosition), take the fragment and activate the link. See also QTextControlPrivate::activateLinkUnderCursor.

    (Of course, you may choose to just use those private classes, with all the pros and cons.)



  • Subclass might be the optimum solution, but i haven't done it before. Like inheriting some properties of another class into existing one. Can you help me out??
    QTextCursor cursor = ui->textEdit->textCursor();
    Link is a String which is got by Dialog
    cursor.insertHtml(link);



  • Subclassing is a basic element of the C++ language (and most (all?) object oriented languages for that matter). Qt is not going to free you from learning the language you write your code in. Perhaps you should pick up a beginners C++ book and start at the basics.



  • Hi, i have made subclass of QTextEdit and its working too.
    But when i try to subclass the QTextEdit along with the Mainwindow and Myclass , i am getting some problem. i dont know how to implement it .
    Give me some lead.



  • Your question is not realy clear to me. What exactly do you try and what goes wrong?



  • [quote author="leojoseph" date="1295954145"]Hi, i have made subclass of QTextEdit and its working too.
    But when i try to subclass the QTextEdit along with the Mainwindow and Myclass , i am getting some problem. i dont know how to implement it .
    Give me some lead.[/quote]

    The crystal ball is on hiatus today, sorry. So, we're in dumb mode now and unfortunately unable to guess what you meant.

    If you have a problem, you surely are able to explain to others what it is, so that they can understand it. If not, you have an even bigger problem, but that cannot be solved by the community.



  • Previously i had created QTextEdit class and made use of that in Myclass.

    Now I want to know how to subclass QTextEdit,QMouseEvent along with the QMainWindow and Myclass.

    Eg: class Myclass:public QMainWindow,QTextEdit like that,

    Note(Mouse Event in TextEdit)



  • Sorry, I'm lost.



  • Me too...
    you want to make a widget which is a cmobination of mainwindow and textedit?
    why noz just make a myclass and put a myedit as child.
    myedit would be derived from textedit?

    Is it that what you want?

    Sorry, I'm just guessing....



  • Ya almost like that. Let me Clear.

    See,I have already created a class name Random which inherits QTextEdit.
    Now i have to use the Random class to Myclass, where Myclass already contains QMainWindow.

    In Brief: The Myclass project contains a textEdit widget and a PushButton, i need to invoke a mouse event in the textEdit widget. So i created a Random Class which inherits the QTextEdit. If i make use of the Random Class in the Myclass , i can make my Req done.



  • Sorry, now you lost me too....



  • Oh!! Its Just Like implementing the Custom Widgets!!

    I have created the class and its functions, all i need to do is integrate the two classes.



  • No Probs!!

    Why always the Hyperlink click is working in QT(QTextEdit) but the URL is not working!!

    If i type www.mail.google.com , its not working.

    But if i type http://mail.google.com is working!!

    Do you know why ??
    And is there any breakthrough for this?


Log in to reply
 

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