Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (0)


Calls to Qt cause installation problems for components in Kylix BCB IDEFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Kylix
Category:
Kylix Others
Skill Level:
Scoring:
Last Update:
01/29/2003
Search Keys:
delphi delphi3000 article borland vcl code-snippet Qt QGraphics CLX Kylix installation Linker-Error QPainter_rotate QPainter_translate qpainter.hb.
Times Scored:
1
Visits:
3680
Uploader: Richard Winston
Company:
Reference: N/A
 
Question/Problem/Abstract:
If a component written in Delphi makes a call to Qt, installing the component in the Kylix BCB IDE can be difficult. This article describes how to overcome this problem
Answer:



I had problems with a component I wrote that used calls to Qt.  

The procedure that caused the problems wrote Text at location (X,Y) at an angle specified by Angle using the following code.

Uses Qt, QGraphics;

procedure TRbwRuler.PaintRotated(const X, Y, Angle: double;
  const Text: string);
begin
  Canvas.Start;
  QPainter_translate(QPainterH(Canvas.Handle),X,Y);
  try
    QPainter_rotate(QPainterH(Canvas.Handle),Angle);
    try
      Canvas.TextOut(0,0,Text);
    finally
      QPainter_rotate(QPainterH(Canvas.Handle),-Angle);
    end;
  finally
    QPainter_translate(QPainterH(Canvas.Handle),-X,-Y);
    Canvas.Stop;
  end;
end;

This worked just fine in the Kylix Delphi IDE. but it wouldn't compile with the Kylix C++ IDE. The error messages were

[Linker Error] Unresolved external
'Qt::QPainter_translate(QT::QPainter *, double, double)' referenced from QrbwRuler.o

and

[Linker Error] Unresolved external 'Qt::QPainter_rotate(QT::QPainter *, double, double)' referenced from QrbwRuler.o

I could write a similar component in the Kylic C++ IDE using code like this.

void __fastcall TRbwRuler::PaintRotated(const double X, const double
Y,   const double Angle, const AnsiString Text)
{
  Canvas->Start();
  Qt.QPainter_translate((QPainter__*)Canvas->Handle,X,Y);
  __try
  {
    Qt.QPainter_rotate((QPainter__*)Canvas->Handle,Angle);
    __try
      {
      Canvas->TextOut(0,0,Text);
      }
    __finally
      {
      Qt.QPainter_rotate((QPainter__*)Canvas->Handle,-Angle);
      };
  }
  __finally
  {
    Qt.QPainter_translate((QPainter__*)Canvas->Handle,-X,-Y);
    Canvas->Stop();
  };
}

I could get components that worked in either IDE by declaring a virtual, abstract procedure and then declaring two new components - one for each IDE - and overriding the abstract procedure with the code that works in that IDE.  

However, if you want to use visual form inheritance in the C++ IDE to inherit from forms created in the Delphi IDE, this doesn't work.  I could view such forms in the IDE but when I tried to compile the project, it reported linker errors.  This appeared to be because the Delphi and C++ versions of the component really weren't the same thing even though they had identical names and functionality.

This is really the same sort of problem I was trying to avoid in creating the two components in the first place.  The C++ IDE and Delphi IDE appear to need different versions of QPainter_translate and QPainter_rotate.  The Delphi IDE appears to wants the one declared in Qt.pas whereas the C++ IDE appears to want the one declared in qpainter.hb.  

My final solution was to install the component in the C++ IDE as a package

Select Component|Install Packages…
Click the Add... Button.
Select a *.so file generated by the Delphi IDE.
Click the Open button.
Click the OK button.

For each package, you need to generate an *.a file.  

File|CloseAll
File|New|Other|Library
File|Save Project As… and save with the same root name as the Package file for the Delphi IDE
Project|Add to Project
Select the *.so file.
File | Save All
Now you are ready to actually build the library, so: Project | Build
Click the OK button.

For each source file you also need to generate an *.hpp file.  You can do this by adding the Object Pascal source file to a package and trying to compile the package.  Even though, it may not be possible to compile the Object Pascal source file in the C++ IDE, an *.hpp file will still be generated.

File|Close All
File|New|Other|Package
File|Save Project As… and save with any name but in the same directory as the component source file.
Project|Add to Project
Select the Object Pascal file.
Click the Compile button on the Package dialog box.
Click the Make button.
It is not necessary to click the install button too.

If an Object Pascal component has been changed, it may need to be removed from the C++ IDE and then added back to it to get it to function correctly.  It may also be necessary, to generate new *.a and *.hpp files.

The Open Edition of Kylix will not create *.a files in this manner.  However, you can still install and use your components if you uncheck the "Build with runtime packages" checkbox in the "Component|Install Packages" dialog box.  





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment













 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
Peganza
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)