2

I'm trying to use ChangeWindowAttributes() function in Qt Creator project on Mac OS X. But I can't build the project.

What I've tried:

#include <MacWindows.h>

Result (compiler): File not found

#include <Carbon/Carbon.h>

// Or the same:
#include </Developer/Headers/FlatCarbon/MacWindows.h>

Result (compiler): ChangeWindowAttributes was not declared in this scope

#include <Carbon/Carbon.h>
extern OSStatus ChangeWindowAttributes (
   WindowRef window,
   WindowAttributes setTheseAttributes,
   WindowAttributes clearTheseAttributes
);

// And in *.pro file:
LIBS += -framework Carbon

Result (linker): Undefined Symbols ChangeWindowAttributes( ...

Where am I wrong?

According Google it seems that everybody already knows how to include it, so there are no guides anywhere. Maybe someone here also has a link to the guide or something?

Pavel Koryagin
  • 1,479
  • 1
  • 13
  • 27

1 Answers1

1

By default, QT Creator build your project in your Mac's CPU architecture. The libraries themselves come in x86 and x86_64 universal binaries. This is if you are using the prebuild SDK from Nokia.

If you are running 64-bit capable OS/Mac combination, like 10.6 on a new Intel Mac, it will build it in x86_64. Carbon calls are still available to your code but only those marked as 64-bit compatible one. Open MacWindows.h and find ChangeWindowAttributes. You will see in the comment:

 *  Availability:
 *    Mac OS X:         in version 10.0 and later in Carbon.framework [32-bit only]
 *    CarbonLib:        in CarbonLib 1.0 and later
 *    Non-Carbon CFM:   not available

If you have to call this (and other 32-bit only) function, you'll have to force Creator to build it in 32-bit (x86). Add these lines to your .pro file:

CONFIG -= x86_64
CONFIG += x86

Clean all and rebuild.

Stephen Chu
  • 12,724
  • 1
  • 35
  • 46
  • Thank you. This really matters. But what is the replacement for ChangeWindowAttributes under 64 bit with Qt's QWidget::winId()? – Pavel Koryagin Apr 28 '11 at 17:38
  • I have no idea. There might not be one. Apple pretty much just left Carbon bled to death without much even pretending they care. You may be able to find something in Cocoa with Obj-C interface. But the question is, why are you doing this in a Qt project? If you have some specific need, you should post a question on how to accomplish it with Qt. – Stephen Chu Apr 28 '11 at 18:31
  • You're right. I've posted the original problem: http://stackoverflow.com/q/5823700/698843 Actually, we thought it is unsolvable in Qt, but hope we were wrong. – Pavel Koryagin Apr 28 '11 at 19:08