Add example program and make this repository compile by itself.
If I understood it correctly, this repository was meant to be used as a submodule in an other project and therefore the CMakeLists.txt file was kept minimal. I on the other hand wanted to test this repository and check whether it compiles and runs with my current setup [compiler, Qt version]. To that end I would have liked a minimal example.
In addition I was somewhat confused about the "INTERFACE" nature of the "library". If you don't like my changes regarding to that point, simply let me know and I can revert them.
So thanks for this great project. And I would be glad about any feedback.
So the idea is to make QHexView as static library with a "sample" executable?
The sample code can be simplified as (not tested!):
#include <QApplication>
#include <qhexview/qhexview.h>
int main(int argc, char** argv) {
QApplication a{argc, argv};
QHexDocument* doc = QHexDocument::fromFile(QApplication::applicationFilePath());
QHexView view;
view.setDocument(doc); // No parent, it takes the ownership of 'doc'
view.show();
return a.exec();
}
I have read quickly the updated CMakeLists.txt, I think it can be simplified again, I will read it and report some changes, if needed!
Thanks for the feedback.
Feel free to let me know about any desires to simplify the CMakeLists.txt files.
Or if you feel like it, feel free to adapt them yourself. I don't mind.
I just integrated this widget into my app, and my experience is ... just boringly good :)
I am using CPM for integration, then in my CMakeLists.txt added:
CPMAddPackage("gh:Dax89/QHexView#v5.0.0")
...
target_link_libraries(myapp PUBLIC ... QHexView)
Inside your code you just:
#include <model/buffer/qmemorybuffer.h> // I needed this for my own code
#include <qhexview.h>
And it just works. My CICD also compiles for windows, and I got no errors. It just works.
This commit https://github.com/Dax89/QHexView/commit/2bafc90b79d0957374babf682832e347e8a1d89f reorganizes the source tree, I have also added an example and changed CMake's target in order to generate a static library.
See here for more details: https://github.com/Dax89/QHexView/discussions/83?converting=1#discussioncomment-10846595.
Let me know if I have missed something!
diff --git a/src/qhexview.cpp b/src/qhexview.cpp
index 1d44009..2af7d25 100644
--- a/src/qhexview.cpp
+++ b/src/qhexview.cpp
@@ -18,7 +18,7 @@
#include <limits>
#if defined(QHEXVIEW_ENABLE_DIALOGS)
-#include "dialogs/hexfinddialog.h"
+#include "QHexView/dialogs/hexfinddialog.h"
#endif
#if defined(QHEXVIEW_DEBUG)
@diegoiast fixed and pushed, thanks!