PDA

View Full Version : How to create a HyperLink in Qt 4.1.5?



vishal.chauhan
17th May 2007, 08:19
Hi All,

I m using Qt 4.1.5 on my Intel Mac.
I want to create a Link in Qt. I can make a Link in Qt 4.2.2 but Actually QT 4.2.2 does not give support to MAC 10.2 so I have to use Qt 4.1.5.

So If anybody knws then plz help me.

Thanks.

Teerayoot
17th May 2007, 14:26
Sub class QPushButton

reimplement all of these events

virtual void enterEvent(QEvent *);
virtual void leaveEvent(QEvent *);
virtual void paintEvent(QPaintEvent *);

You can change mouse cursor when mouse enter
and change back when mouse leave

painter use for Draw Text look like link color

marcel
17th May 2007, 19:33
Or use a QLabel or QWidget to do the same thing, because QPushButton is too "heavy" for such a small task.

Regards.

patrik08
17th May 2007, 19:39
Hi All,

I m using Qt 4.1.5 on my Intel Mac.
I want to create a Link in Qt. I can make a Link in Qt 4.2.2 but Actually QT 4.2.2 does not give support to MAC 10.2 so I have to use Qt 4.1.5.

So If anybody knws then plz help me.

Thanks.




Link?? a href link or start a link file like a pdf same as terminal:
mac:

open file.pdf

http://doc.trolltech.com/4.2/qdesktopservices.html





/* qt2 > */
void FullEdit::OpenDesktop( QUrl loc )
{
qDebug() << "#### OpenDesktop " << loc;

#if defined Q_WS_WIN

QString winbuh = DesktopFile(loc.toString()); /* attach file:// if a local url */
/* QUrl(winbuh) */

bool wr = QDesktopServices::openUrl(loc);
if (!wr) {
QMessageBox::warning(0, tr("Error"),tr("Unable to open file or dir %1").arg(loc.toString()));
}
return;
#endif


bool r = QDesktopServices::openUrl(loc);
if (!r) {
QMessageBox::warning(0, tr("Error"),tr("Unable to open file or dir %1").arg(loc.toString()));
}
}


/* qt2 < */


void ClassName::OpenUrl_File_Dir_Dektop()
{
#if defined(Q_WS_WIN)
QProcess p;
QStringList s;
s << "url.dll,FileProtocolHandler" << "http://www.qtforum.de/forum/";
p.startDetached(QString("rundll32.exe") , s );
#endif
#if defined Q_WS_MAC
QProcess m;
QStringList macs;
macs << "http://www.qtforum.de/forum/"; /* oeffnet der default browser */
m.startDetached(QString("open") , macs );
#endif
}

patrik08
17th May 2007, 19:48
ONLY on MAC!
IMO...
if you show last line from http://www.qtforum.de/forum/viewtopic.php?t=2366 only source ...

you can make applescript and set image backround or other 1000 way applescript ... like make a coffe...

wysota
17th May 2007, 22:23
Patrick... the question was about Qt 4.1. And it was about displaying a link and not opening pdf files...

vishal.chauhan
18th May 2007, 05:30
Thanks for Reply.

But as Wysota said question was how to create hyperlink in Qt 4.1.5 not in Qt 4.2.

marcel
18th May 2007, 06:36
Look at posts #2 and #3.

Regards