Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yg17

macrumors Pentium
Original poster
Aug 1, 2004
15,027
3,002
St. Louis, MO
I'm a computer science major, and for our assingments, we have to use visual studio.net and c++ to write a program with a GUI. Unfortunatley, I'm forced to use windows for this work. I'd like to teach myself how to write programs with GUIs using C++ anyways, since right now on a Mac or *nix system I can only do boring terminal programs. I looked around x-code, and it seems to only work with GUIs and Objective C and Java. I'd rather get used to XCode with what I already know, so is there a way to use C++ to write programs with GUIs? Thanks
 

csubear

macrumors 6502a
Aug 22, 2003
613
0
GUIs are rather OS dependent. Well really they are framework (library) dependent. When working in Windows you'll be using the MFC or .Net Frameworks, and on OS X you'll be using the Carbon or Cocoa frameworks. These frameworks are mutually exclusive.

Now.. if you really wanted to write software that would compile on window/mac/X11(unix) then check out qt by trolltech. Its a nice windowing framework that has implementations on all major platforms.
 

yg17

macrumors Pentium
Original poster
Aug 1, 2004
15,027
3,002
St. Louis, MO
csubear said:
GUIs are rather OS dependent. Well really they are framework (library) dependent. When working in Windows you'll be using the MFC or .Net Frameworks, and on OS X you'll be using the Carbon or Cocoa frameworks. These frameworks are mutually exclusive.

Now.. if you really wanted to write software that would compile on window/mac/X11(unix) then check out qt by trolltech. Its a nice windowing framework that has implementations on all major platforms.

Im not looking for cross platform compatibility. Just something like VS.net/MFC for Mac where I make a GUI interface then write c++ code to interact with it
 

jadam

macrumors 6502a
Jan 23, 2002
699
2
Use XCode + Interfacebuilder, it kicks major ass. Objective-C is a great language too :-D
 

dweebert

macrumors newbie
Oct 20, 2003
26
0
Objective C's dynamic runtime makes it particularly useful for user interface work. Rather than defining integer constants for actions, coding in callbacks, or (ugh) letting a graphical editor write C++ code for you, you simply draw lines in interface builder, and let the runtime find the right methods and instance variables when the program is executing. Forget about the old "subclassing the dialog" approach!

If you have a reasonably good understanding of C and object oriented principles, it is really easy to learn Objective C. If you can get a book like Aaron Hillegass' "Cocoa Programming for Mac OS X", you'll learn all you need to get started in one evening.

You'll wonder why they teach C++ GUI programming at all. (The conspiracy theorist in me presumes your school gets some nice kickbacks from Redmond, though.)
 

csubear

macrumors 6502a
Aug 22, 2003
613
0
You can use c++ with obj-C. I have done this before. I think you need to use a complier flag to get this to work. The idea is you create your c++ backend, and then create a controller class that interfaces to the GUI for each gui framework you want to use.
 

yg17

macrumors Pentium
Original poster
Aug 1, 2004
15,027
3,002
St. Louis, MO
dweebert said:
You'll wonder why they teach C++ GUI programming at all. (The conspiracy theorist in me presumes your school gets some nice kickbacks from Redmond, though.)

Considering I can probably count the number of Macs on campus outside of the dorms on one hand, I think you may be right.

Thanks everyone, Ill look into it
 

Mitthrawnuruodo

Moderator emeritus
Mar 10, 2004
14,453
1,112
Bergen, Norway
Qt from Trolltech provides you with a library for GUI programming, and has some tools for designing widgets. It also has the benefit of being a cross platform library, so your code should work on Macs/linux/Windows. Easy to lern, easy to use, I recommend it strongly...
 

MacNeXT

macrumors 6502
Jun 21, 2004
258
0
kingjr3 said:
Obj-C isn't much of a stretch from C++. A couple different syntatical differences, but the ideas are the same. I recommend you give it a try and then you can leverage all the Cocoa Frameworks/APIs.

Altough learning Obj-C isn't difficult if you have previous knowledge of C++ or Java, I would not say there are only syntactical differences. The syntactical difference is just something to get used to.

However, Obj-C's dynamic typing, as opposed to C++ and Java's static typing, requires a completely different way of thinking about your OO designs. Only when you're aware of this, you will be able to use Obj-C's advantages to their full extent.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.