PDA

View Full Version : Open file from Qtext browser



mecrazycoder
5th January 2011, 15:24
I wrote a code to open file in gedit by clicking a link which is displayed in QTextBrowser. But file is not getting open in gedit instead it is displaying QTextBrowser itself. Here is my code


void MainWindow::openTextEdit()
{
QTextBrowser *p = new QTextBrowser();
p->show();

p->append("<a href = \"/home/winbros/Test.cpp\"> Link </a>");
p->setOpenExternalLinks(true);
}. Tanx in advance

Lykurg
5th January 2011, 15:27
And where in the code you tell that you want to open it in gedit? Fetch the signal when the link is clicked and open gedit with a QProcess or so.

mecrazycoder
5th January 2011, 21:26
Sorry I dnt know about QProcess. Can you please give me a pseudocode for it. What if I want to open all formats like doc,xls,ods etc.

Lykurg
5th January 2011, 22:00
In the manual you'll find a good explanation: QProcess, or have a look at QDesktopServices::openUrl ().

mecrazycoder
7th January 2011, 09:56
Could you please let me know how to keep track which link as been linked by the users. Further I looked into anchorclicked by I dnt how to use it in this context. P.S. I am using QT creator