X Windows C++ examples

Posted on 2006-05-08
Last Modified: 2013-12-27
Can someone help me to find an example of an X-Windows graphical program written in C++ or C.
I'm looking for something like a hello world application. I'd like to see how to implement a button or some simple control.

Question by:funkyfinger
    LVL 2

    Author Comment

    I'm starting to realize that this is a very broad question, as I research it I'm finding that the desktop I want to use GNOME uses a x window system called sawfish. I don't know if I can write generic code for both GNOME and KDE or for any x window system.

    Still looking..
    LVL 11

    Accepted Solution

    If you want to go multi platform, you have
    1) QT
    2) WxWindows
    3) FLTK

    Might be easier using one of these as you can switch from Unix to Windows and not worry about it.  The examples are with the sources that you download.
    LVL 2

    Author Comment

    I'm not worried about MS Windows at all. I just want to program for any (I should say most or hopefully some) Linux distributions.
    LVL 3

    Assisted Solution

    Xwindows run on almost any machine -- cygwin is pretty good (for mswindows machines).

    But saying "I want to write an X window application" -- there are so many approaches:
      1) raw X
      2) toolkit (i.e. kde, wxwidgets)
      3) scripting language (i.e. tcl/tk)

    All of these are viable and useful.

    LVL 2

    Author Comment

    Hmm,, maybe there is something I'm not getting. Or maybe I'm not communicating well.
    I'm a pretty fair programmer, but I'm new to linux.  Normally I'd use MS's MFC to write graphical programs.  But in Linux I'm clueless.
    I'd like to use C++ to write the graphical program. (by graphical program I mean a form with buttons, textboxes, checkboxes and so forth.)

    I'm concerned about standard controls, for instance a clickable button. In MS Windows the space bar can be used to simulate a button click, or toggle a checkbox, also the tab key cycles though these controls. I want to keep with standard controls if they exist. I don't know if linux has standard controls like this.  I want to learn about how to go about writing this type of progam.

    After I am comforable with this I  plan to go wth linux full force and get my company to adopt open source solutions.

    Thanks for your help
    LVL 2

    Author Comment

    Ahh,, thanks for your help
    LVL 3

    Expert Comment

    The  beauty of Unix systems is "if you don't like something, do it your own way"

    Hence a plethora of shells, window toolkits, etc.

    I guess if you're talking about a "standard way"  -- like Andy Tanenbaum says "the wonderful thing about standards is there are so many of them".

    The windowing system is just another application you talk to .

    At the lowest level (I guess  the "standard") is X11.

    Then there are lots of "toolkits" built upon them them you can use.

    I would imagine there is an article aimed at exactly what you want to do...

    I guess pick one and go with it...QT is fine...


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    VMWARE coldclone Freebsd partitions all screwed up. 9 141
    Bash Script Help 3 264
    Convert OverPunch 25 48
    NTP Server in VMware 5 88
    Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
    Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now