c++ and interface

Discussion in 'Mac Programming' started by yg17, Feb 7, 2005.

  1. macrumors G5

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #1
    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
     
  2. macrumors 6502a

    csubear

    Joined:
    Aug 22, 2003
    #2
    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.
     
  3. thread starter macrumors G5

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #3
    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
     
  4. macrumors 6502a

    jadam

    Joined:
    Jan 23, 2002
    #4
    Use XCode + Interfacebuilder, it kicks major ass. Objective-C is a great language too :-D
     
  5. macrumors newbie

    Joined:
    Oct 20, 2003
    #5
    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.)
     
  6. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #6
    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/
     
  7. macrumors 6502a

    csubear

    Joined:
    Aug 22, 2003
    #7
    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.
     
  8. thread starter macrumors G5

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #8
    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
     
  9. Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #9
    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...
     
  10. macrumors 6502

    Joined:
    Jun 21, 2004
    #10
    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.
     
  11. thread starter macrumors G5

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #11
    qt is 560 bucks? or am I missing a free version somewhere?
     
  12. Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #12
    There is both an Open Source license and an Educational license, if you're connected to an educational institution...

    You can download the Open Source version here...

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

    Enjoy!
     

Share This Page