Klaus
Klaus

Reputation: 25603

gui toolkit with c++ interface and inteligent canvas support needed

I have a lot experience in tcl/tk, but I want to get rid of scripting languages for large projects. But tk canvas has a very big functionality which I have to replace with a good gui toolkit.

One of the features I need is a canvas on which I can create active graphical objects. For example, I have a circle which can be moved by mouse drag like this in tk:

    #!/usr/bin/wish8.5

    canvas .c
    pack .c
    set item [.c create oval 10 10 20 20] 

    .c bind $item <Any-Enter> ".c itemconfig current -fill red"
    .c bind $item <Any-Leave> ".c itemconfig current -fill blue"

    bind .c <ButtonPress-1> "setlast %x %y"
    bind .c <B1-Motion> "moveit %x %y"

    set lastx 0
    set lasty 0

    proc setlast { x y } { 
        global lastx
        global lasty
        set lastx $x
        set lasty $y
    }   

    proc moveit { x y } { 
        global lastx
        global lasty
        .c move current [expr $x-$lastx] [expr $y-$lasty]
        set lastx $x
        set lasty $y
    }

Any other toolkit I found needs a lot of handcrafted work for this. Typically you have to find out yourself which item on a canvas is under the mouse which is a very large amount of work for complex shapes like polygons.

Upvotes: 1

Views: 397

Answers (2)

Jan Laloux
Jan Laloux

Reputation: 249

I tried C++/Tk but left that path. It does not support all of Tk, eg the featured widgets such as notebook and treelist are not supported, or you cannot pass parameters to a command. Furthermore, the implementation is quite complex and if something is not working as expected it's heavy to debug. Frustrated after a week of problem solving I decided to dump C++/Tk.

Exit C++/Tk, enters Qt (you should say "cute", but it's a bit silly, so I say "queue tee"). It has a commercial but also an open source license, there is active development going on, it is well documented with plenty of examples, it supports most desktop and mobile OSes, there is an active community with wiki and blogs, ... Besides the GUI and graphics stuff there are other modules available for multimedia, networks, SQL, testing, ...

As the development of QT started way back in 1991 (and it was part of Nokia for some time), there are some parts that are "old" and replaced by new stuff, but in contrast to Microsoft the documentation is much clearer on this. And also in contrast to Microsoft, the whole set of technologies is coherent.

For the integration with C++ there are two ways:

  1. Use MSVS and the QT add-in. I tried that but couldn't make it work as it should. Maybe I should have tried more, but after two days trying I had enough of it.
  2. Use the QT IDE that will use the C++ compiler you have installed. This works fine and that's the way I am doing it now. A disadvantage is that the edit time error checking is not that strong as in MSVS. An advantage however is that when you have the free version of MSVS you are able to compile for 64 bit too.

If you want to make a GUI you should definitely consider Qt.

Upvotes: 1

PaulD
PaulD

Reputation: 212

Have you tried GTK+ or QT? Well, QT mostly is a platform for development, not a GUI library, but you can try it's too.

Upvotes: 1

Related Questions