开发者

C++ Analogue for WPF

开发者 https://www.devze.com 2023-03-26 14:32 出处:网络
So I\'ve fooled around with WPF a bit recently, and I must say that I really like the idea. I love the framework as a whole, from the GUI to the plumbing.

So I've fooled around with WPF a bit recently, and I must say that I really like the idea. I love the framework as a whole, from the GUI to the plumbing.

However, as much as I love managed land, I love my native code just as much. So I'm wondering what sort of libraries exists for C++ which capture the essence of various parts of WPF. I'm not looking for interop solution, nor do I want Managed C++ or C++/CLI solutions, but pure C++ solutions.

Now, I'm not expecting to find a "copy" of WPF for C++ - I wouldn't expect that to exist, nor would I need it to. Instead, I would expect that different libraries might capture a subset of the desired concepts. My particular interests are

  1. Hardware accelerated graphics for widget based GUI's (via DirectX or OpenGL, preferably the latter)

  2. Declarative language for GUI design (preferably an XML dialect)

  3. Data binding

  4. Resolution independence (less important)

To say a little about my reasoning, I would like to implement such a library myself, which captures a specific model that I have begun working out. I am in the process of finding some more inspiration and helpful resources before locking down my design. The library is intended to be cross-platform, so references to cross-platform ideas would be great, but not strictly necessary as I am usually capable of translating things into cross-p开发者_如何学Clatform solutions.

Lastly, although I am writing a C++ library, and C++ ideas would be great, I am open to ideas from any native language.

Thanks in advance for any help.


  1. There isn't really anything like this. Not cross-platform at any rate. Direct2D works reasonably well, but is obviously Windows-only. And NVIDIA recently dropped this "path" extension of OpenGL that is similar in basic functionality, but it is NVIDIA-only (and not available on Mac OSX). Cairo has an OpenGL backend, but I have no idea how good it is. It can't be that good if Mozilla dumped Cairo in favor of D2D on Windows.
  2. Many GUI toolkits have some form of language for making a GUI. Qt has one that is pre-compiled into C++.
  3. Not that I know of. Data binding requires some form of reflection (WPF-style data binding does), and C++ has no native support for reflection. So you would need to implement reflection of some sort before you can even begin to make WPF-style data binding work.
  4. That comes with #1. More or less, as any GPU-based renderer will be able to operate at arbitrary resolutions.

I love C++, but honestly, this sort of thing is best implemented for a higher level language. The lack of language-based reflection support will make implementing data binding a huge pain. Whereas, you could just implement the low-level "render stuff to area" and basic window/event management in C++, then expose it to a scripting language where data binding and such work. That way, you have native code speed where you need it, but the versatility and reflection of a scripting language for dealing with the GUI and its associated data.


I'm several years late, but for the benefit of anybody else reading this question: you're looking for Qt Quick / QML:

http://qt-project.org/doc/qt-4.8/qml-intro.html

http://doc.qt.io/qt-5/qtqml-cppintegration-topic.html

0

精彩评论

暂无评论...
验证码 换一张
取 消