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

Qt-interest Archive, March 2002
Problems porting application to windows


Message 1 in thread


<<< text/html: EXCLUDED >>>


Message 2 in thread

Sean,

maybe the answer to question 4: I'm using a little utility called 
"DebugView" that captures the debug output from any program without an 
active debugger running. It's downloadable from http://www.sysinternals.com

Fabian
-- 
 [ signature omitted ] 

Message 3 in thread

Sean Murphy wrote:
Sean,

> I'm having a couple of issues porting my application over to
> Windows:First off, the application compiles and works fine under
> Linux.  I've created a .pro file that qmake produces a Makefile from
> and make makes without any warnings or complaints.  Now for the
> Windows problems:1.  qmake on Windows (using "qmake -o Makefile -spec
> win32-msvc") works fine, but running nmake on the resulting file
> generates a bunch of errors when it tries to link all the *.o files
> together.  The errors are all saying that I have multiply defined
> class in moc_*.cpp and *.cpp.  In other words, from all the *.ui files
> the compiler seems to be making an moc_*.cpp AND a *.cpp, then an
> moc_*.o AND a *.o, and then trying to link them together.  The only
> way I can get it to compile is to put /FORCE:multiple in the LINK =
> line in the Makefile.  Is there something I'm doing wrong here?2.  My
> application is going to be running on an 800x600 monitor all the time,
> so I've got the following in my main.cpp:

> Pilot_DisplayImpl *pilot_display=new Pilot_DisplayImpl();
>   pilot_display->setGeometry(0,0,pilot_display->width(),
> pilot_display->height());
>   a.setMainWidget(pilot_display);The intent of the setGeometry()
> command is to pin the upper left corner of my widget in the upper left
> corner of the desktop and set the size of my widget to 800x600.  The
> Pilot_DisplayImpl constructor sets the size of itself to 800x600 so
> that I can call the width() and height() commands.  When I compile and
> run the program under Linux I get what I want, the window is all the
> way in the upper left corner (one note here is that the desktop on the
> Linux machine is much bigger than 800x600).  Under Windows however,
> where the screen resolution is set to 800x600, what I end up seeing is
> my widget taking up the whole screen, and the Title bar is pushed off
> the top of the screen.  (I think Title Bar is the right term, it's the
> bar that has the minimize, maximize, close buttons on it as well as
> the application's name and icon)   So when I run my application on
> Linux I can click the 'X' in the upper left corner to close the
> application, but under Windows I can't because it is off the top of
> the screen.  Do I need to set the last parameter in the setGeometry()
> call to be something like (pilot_display->height() -
> HeightOfTitleBar)?

Don't know for sure ( as I don't use Windows), but maybe you can't use
the whole 800x600 area on windows? Perhaps make it a bit smaller?Does it
have to be exactly 800x600?

> 3.  I'm trying to store the server name and port number that my
> application connects too using QSettings.  I've got this in my
> widget's constructor:  QSettings settings;
>   settings.insertSearchPath( QSettings::Windows, "/MyCompany" );
> SERVER_NAME = settings.readEntry( "/Pilot_Display/server name",
> "dcs-ws1", &settingsValid );
>   PORT_NUM = settings.readNumEntry( "/Pilot_Display/server port",
> 5000, &settingsValid);Then later when I close my application, it saves
> the current settings out:  QSettings settings;
>   settings.insertSearchPath( QSettings::Windows, "/MyCompany" );
>   settings.writeEntry( "/Pilot_Display/server name", SERVER_NAME );
>   settings.writeEntry( "/Pilot_Display/server port", PORT_NUM);Under
> Linux this works correctly.  Under Windows this doesn't seems to
> work.  I can't seem to find anywhere in the registry where anything is
> being stored, so every time I launch the application it tries to
> connect to dcs-ws1, instead of the last server it was able to connect
> to.

Can't comment on QSettings, but as for the debugging messages you can
install a handler yourself and do whatever you like with them, see the
docs for
QtMsgHandler qInstallMsgHandler ( QtMsgHandler h ) .
funktion. It's dead easy, just a function pointer which you install, it
must only be of type QtMsghandler, for its prototype please see file
qglobal.h.
In my application I use a command line switch to turn all messages on or
off.

> 4. My application has a bunch of qDebug() messages in it.  When I
> execute the application from the command line under Linux, I see my
> debug message being printed.  If I run the application under Windows
> from a Command Prompt, the application just runs and I don't see any
> messages.  So on Windows, where does qDebug() print to and how can I
> see it?  The documentation says that under Windows, the messages are
> sent to the debugger, so does that mean I can only see the messages if
> I run my program in MS Visual C++?  If so this is going to be a
> problem since the computer I'm trying to run this program on isn't a
> development machine and doesn't have Visual C++ on it (and it isn't
> going to be possible to put it on there either - long story...).  So
> maybe I want to use cout statements instead?Sorry my e-mail is so

you could very well use cout in the message handler you write and
install yourself. In that function you have full control of them. From
the docs:
<snip>
  #include <qapplication.h>
    #include <stdio.h>
    #include <stdlib.h>

    void myMessageOutput( QtMsgType type, const char *msg )
    {
        switch ( type ) {
            case QtDebugMsg:
                fprintf( stderr, "Debug: %s\n", msg );
                break;
            case QtWarningMsg:
                fprintf( stderr, "Warning: %s\n", msg );
                break;
            case QtFatalMsg:
                fprintf( stderr, "Fatal: %s\n", msg );
                abort();                        // dump core on purpose
        }
    }

    int main( int argc, char **argv )
    {
        qInstallMsgHandler( myMessageOutput );
        QApplication a( argc, argv );
        ...
        return a.exec();
    }

</snip>

> long!Sean

/G

--
 [ signature omitted ] 

Message 4 in thread

I've got a couple of the issues taken care of.  I can now see the debug
message on the console, I've got the settings working, and I think I've
got the window positioning done too, but just haven't tried it yet.

Now that I have the debug messages working, I've discovered another
problem, my client is not able to resolve a host name into an IP
address.  My client is going to be running on a laptop that is making a
direct connection over a serial cable to a Linux machine running pppd.
We have the hosts file on the Windows machine set up to resolve the
machine names that my client will be connecting to into IP address on
our network.  This seems to work fine for other application but not
mine.  For example, from a windows command prompt, I can telnet into the
Linux (called 'pdg' in the hosts file) by typing "telnet pdg".
Similarly, I can ping pdg with "ping pdg".  Both of these commands show
pdg resolving to 192.168.19.6 which is the correct IP address.  My Qt
client however hangs on host lookup.  I have debug message set up right
before my socket.connectToHost() call, and I have a slot connected to
the socket::hostFound() signal that does a qDebug("Host lookup
succeeded!").

So I guess my question is, does Qt look at the hosts file (located at
C:\Windows\hosts) under windows?  It doesn't seem to be from what I'm
seeing happen.  This machine doesn't have a name server that it can see,
so we need to rely on it being able to resolve IP's from the hosts file.
The Microsoft created products seem to see the hosts file without a
problem (no big surprise...) but Qt doesn't seem to check there.  I
guess I could always change my program to parse through the hosts file,
but that seems a bit silly since that is what the hosts file is there
for.

Any thoughts?
Sean  

-----Original Message-----
From: owner-qt-interest@trolltech.com
[mailto:owner-qt-interest@trolltech.com] On Behalf Of Sean Murphy
Sent: Tuesday, March 05, 2002 3:54 PM
To: Qt Interest
Subject: Problems porting application to windows


I'm having a couple of issues porting my application over to Windows:

First off, the application compiles and works fine under Linux.  I've
created a .pro file that qmake produces a Makefile from and make makes
without any warnings or complaints.  Now for the Windows problems:

1.  qmake on Windows (using "qmake -o Makefile -spec win32-msvc") works
fine, but running nmake on the resulting file generates a bunch of
errors when it tries to link all the *.o files together.  The errors are
all saying that I have multiply defined class in moc_*.cpp and *.cpp.
In other words, from all the *.ui files the compiler seems to be making
an moc_*.cpp AND a *.cpp, then an moc_*.o AND a *.o, and then trying to
link them together.  The only way I can get it to compile is to put
/FORCE:multiple in the LINK = line in the Makefile.  Is there something
I'm doing wrong here?

2.  My application is going to be running on an 800x600 monitor all the
time, so I've got the following in my main.cpp:
  
  Pilot_DisplayImpl *pilot_display=new Pilot_DisplayImpl();
  pilot_display->setGeometry(0,0,pilot_display->width(),
pilot_display->height());
  a.setMainWidget(pilot_display);

The intent of the setGeometry() command is to pin the upper left corner
of my widget in the upper left corner of the desktop and set the size of
my widget to 800x600.  The Pilot_DisplayImpl constructor sets the size
of itself to 800x600 so that I can call the width() and height()
commands.  When I compile and run the program under Linux I get what I
want, the window is all the way in the upper left corner (one note here
is that the desktop on the Linux machine is much bigger than 800x600).
Under Windows however, where the screen resolution is set to 800x600,
what I end up seeing is my widget taking up the whole screen, and the
Title bar is pushed off the top of the screen.  (I think Title Bar is
the right term, it's the bar that has the minimize, maximize, close
buttons on it as well as the application's name and icon)   So when I
run my application on Linux I can click the 'X' in the upper left corner
to close the application, but under Windows I can't because it is off
the top of the screen.  Do I need to set the last parameter in the
setGeometry() call to be something like (pilot_display->height() -
HeightOfTitleBar)?

3.  I'm trying to store the server name and port number that my
application connects too using QSettings.  I've got this in my widget's
constructor:

  QSettings settings;
  settings.insertSearchPath( QSettings::Windows, "/MyCompany" );
  SERVER_NAME = settings.readEntry( "/Pilot_Display/server name",
"dcs-ws1", &settingsValid );
  PORT_NUM = settings.readNumEntry( "/Pilot_Display/server port", 5000,
&settingsValid);

Then later when I close my application, it saves the current settings
out:

  QSettings settings;
  settings.insertSearchPath( QSettings::Windows, "/MyCompany" );
  settings.writeEntry( "/Pilot_Display/server name", SERVER_NAME );
  settings.writeEntry( "/Pilot_Display/server port", PORT_NUM);

Under Linux this works correctly.  Under Windows this doesn't seems to
work.  I can't seem to find anywhere in the registry where anything is
being stored, so every time I launch the application it tries to connect
to dcs-ws1, instead of the last server it was able to connect to.


4. My application has a bunch of qDebug() messages in it.  When I
execute the application from the command line under Linux, I see my
debug message being printed.  If I run the application under Windows
from a Command Prompt, the application just runs and I don't see any
messages.  So on Windows, where does qDebug() print to and how can I see
it?  The documentation says that under Windows, the messages are sent to
the debugger, so does that mean I can only see the messages if I run my
program in MS Visual C++?  If so this is going to be a problem since the
computer I'm trying to run this program on isn't a development machine
and doesn't have Visual C++ on it (and it isn't going to be possible to
put it on there either - long story...).  So maybe I want to use cout
statements instead?

Sorry my e-mail is so long!
Sean