PDA

View Full Version : c++ and interface




yg17
Feb 7, 2005, 09:10 PM
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
Feb 7, 2005, 09:59 PM
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
Feb 7, 2005, 10:50 PM
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
Feb 7, 2005, 11:45 PM
Use XCode + Interfacebuilder, it kicks major ass. Objective-C is a great language too :-D

dweebert
Feb 8, 2005, 01:29 AM
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.)

jeremy.king
Feb 8, 2005, 09:23 AM
You can use C++ if you must, but you will have to use the Carbon APIs.

http://developer.apple.com/carbon/

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.

http://developer.apple.com/cocoa/

csubear
Feb 8, 2005, 03:00 PM
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
Feb 8, 2005, 03:25 PM
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
Feb 8, 2005, 04:12 PM
Qt from Trolltech (http://www.trolltech.com/products/qt/index.html) 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
Feb 8, 2005, 04:23 PM
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.

yg17
Feb 8, 2005, 04:29 PM
qt is 560 bucks? or am I missing a free version somewhere?

Mitthrawnuruodo
Feb 8, 2005, 04:37 PM
qt is 560 bucks? or am I missing a free version somewhere?

There is both an Open Source license (http://www.trolltech.com/products/qt/opensource.html) and an Educational license (http://www.trolltech.com/products/qt/edulicense.html), if you're connected to an educational institution...

You can download the Open Source version here (http://www.trolltech.com/download/opensource.html)...

Edit: There is also a 30 day trial of the full commercial suite.

Enjoy!