Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, March 2002
Connecting from Qt to html, pdf, http://, ftp://


Message 1 in thread

Greetings, all,

I've attached a program which can display HTML and PDF, and connect to
http:// and ftp:// sites.  Enjoy.  If you know better ways of doing this,
or what's required for other platforms, please let me and the list know.

The program uses Qt3.0.2, and runs on MAC OS X and Win 2000.  I use Qt to 
get near what I want to do, and then resort to platform-specific code.

MAC: 

The MAC code, and enough coaching to get it working, is from Willard Myers 
in the Qt-interest group.  Thanks, Willard!  His strategy (I think) is to 
ask the OS what it uses to look at various file types, and then do the same 
thing.

MAC Results:

On my development machine, Internet Explorer is set up to look at HTML, and 
in its preferences panel, Acrobat is specified to look at PDF.  Beyond that, 
it's all magic to me -- I'm not a MAC internals guy.

The file connections work fine. I can't test the web connections, because 
my development MAC isn't connected to the internet.  

M A C   N O T E : 

In order for the MAC code to work, you have to add
     -framework Carbon -framework QuickTime -lz
to the LFLAGS variable in the Makefile produced by qmake.  (Is there a way 
to do this from the .pro file?) 

WIN:  

My strategy is to ask the Registry how it handles a protocol or a file type, 
and chase through the Registry to the associated Open command.  To do this, 
I use two undocumented functions in QSettings.  The command I get is supposed 
to be the default handler for the protocol or file type. I clean up the Open 
command, and pass it along with the file name or website name to a QProcess 
object.  

WIN Results:

Accurately second-guessing the WIN Registry is beyond human capability (or 
at least mine).  So, my strategy works "pretty well", rather than perfectly.  
In particular, with Netscape 4.76 and Internet Explorer 5.0, the program 
works fine.  With Opera 6.0.1,  I have to click my program's "open" button 
twice if the browser is not already launched.  (Anyone know how to fix this?)

Weaknesses / Bugs:

My program doesn't know how to check whether the process has launched
successfully, or to shut it down.


I hope this saves some of you some time, and that you find it useful.

Regards,
   Jerry Barenholtz
   jerryb@saltspring.com

Attachment: =?windows-1252?Q?launch=5F8Mar02.zip?=
Description: Zip archive


Message 2 in thread

At 4:06 PM -0800 3/8/02, Jerry Barenholtz wrote:
>M A C   N O T E :
>
>In order for the MAC code to work, you have to add
>     -framework Carbon -framework QuickTime -lz
>to the LFLAGS variable in the Makefile produced by qmake.  (Is there a way
>to do this from the .pro file?)

Yes, there is.  It's in the documentation under "qmake's Advanced Concepts".  For example, this is what I add to my .pro file...

macx {
  DEFINES += TARGET_OS_MAC
  LIBS += -framework QuickTime -framework ApplicationServices -framework CoreServices  -framework Carbon
}
win32 {
  DEFINES += TARGET_OS_WINDOWS
}

Good luck,

Eric Smith
Tarkvara Design Inc.