QTextBrowser link opens Notepad on Windows ???
-
Hello everyone,
I'm facing a problem with the Windows version of my MD editor / browser, using links. I am using the links to navigate between pages in a folder.
On Linux, when the links are clicked, the new page simply displays in the QTextBrowser as intended. However on Windows, Notepad opens.

Here is the method I wrote to handle clicking links :
void Editor::FollowLink(const QUrl& followedFile){ QUrl resolvedURL = GetCurrentTab()->document->baseUrl().resolved(followedFile); qDebug() << "The resolved URL is" << resolvedURL.toString(); QString filePath(resolvedURL.toString()); qDebug() << filePath; if(!filePath.isEmpty()) { QFile openedFile(filePath); if(!openedFile.exists()) { qDebug() << filePath << " does not exist."; return; } if (!(openedFile.open(QIODeviceBase::ReadWrite))) { qDebug() << "Error : File could not be opened"; return; } GetCurrentTab()->renderDocument->setBaseUrl(resolvedURL); GetCurrentTab()->document->setBaseUrl(resolvedURL); GetCurrentTab()->editor->setPlainText(openedFile.readAll()); GetCurrentTab()->browser->setSource(resolvedURL); GetCurrentTab()->RenderDocument(); openedFile.close(); } SetTabTitle(filePath); }My
browserwidget hassetOpenExternalLinks(true). Moreover, Notepad is not set as the default application for Markdown, but manages to "steal" the file opening from my app ?What could be happening here ? Thanks for your answers !
-
Hello everyone,
I'm facing a problem with the Windows version of my MD editor / browser, using links. I am using the links to navigate between pages in a folder.
On Linux, when the links are clicked, the new page simply displays in the QTextBrowser as intended. However on Windows, Notepad opens.

Here is the method I wrote to handle clicking links :
void Editor::FollowLink(const QUrl& followedFile){ QUrl resolvedURL = GetCurrentTab()->document->baseUrl().resolved(followedFile); qDebug() << "The resolved URL is" << resolvedURL.toString(); QString filePath(resolvedURL.toString()); qDebug() << filePath; if(!filePath.isEmpty()) { QFile openedFile(filePath); if(!openedFile.exists()) { qDebug() << filePath << " does not exist."; return; } if (!(openedFile.open(QIODeviceBase::ReadWrite))) { qDebug() << "Error : File could not be opened"; return; } GetCurrentTab()->renderDocument->setBaseUrl(resolvedURL); GetCurrentTab()->document->setBaseUrl(resolvedURL); GetCurrentTab()->editor->setPlainText(openedFile.readAll()); GetCurrentTab()->browser->setSource(resolvedURL); GetCurrentTab()->RenderDocument(); openedFile.close(); } SetTabTitle(filePath); }My
browserwidget hassetOpenExternalLinks(true). Moreover, Notepad is not set as the default application for Markdown, but manages to "steal" the file opening from my app ?What could be happening here ? Thanks for your answers !
@BastienSante said in QTextBrowser link opens Notepad on Windows ???:
Here is the method I wrote to handle clicking links :
Unfortunately, based on the problem statement, this is code that isn't executed. That doesn't help clarify what is executed.
My
browserwidget hassetOpenExternalLinks(true). Moreover, Notepad is not set as the default application for Markdown, but manages to "steal" the file opening from my app ?What could be happening here ? Thanks for your answers !
QTextBrowser::openExternalLinks:
Specifies whether QTextBrowser should automatically open links to external sources using QDesktopServices::openUrl() instead of emitting the anchorClicked signal. Links are considered external if their scheme is neither file or qrc.Did you intend to set openExternalLinks to
false?