Skip to content

Commit de1725f

Browse files
authored
Qt qcustomplot no download (#16)
* QT: QCustomPlot now stored as source
1 parent 851c5f2 commit de1725f

File tree

11 files changed

+28569
-22
lines changed

11 files changed

+28569
-22
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ jobs:
4646
path: build/data/data/txt
4747
key: data-${{ hashFiles('build/data/data/txt/**/*') }}
4848
restore-keys: data-${{ hashFiles('build/data/data/txt/**/*') }}
49-
- name: deps cache
50-
uses: actions/cache@v2
51-
with:
52-
path: build/deps/dload
53-
key: deps-${{ hashFiles('build/deps/dload/*') }}
54-
restore-keys: deps-${{ hashFiles('build/deps/dload/*') }}
49+
# - name: deps cache
50+
# uses: actions/cache@v2
51+
# with:
52+
# path: build/deps/dload
53+
# key: deps-${{ hashFiles('build/deps/dload/*') }}
54+
# restore-keys: deps-${{ hashFiles('build/deps/dload/*') }}
5555
- name: prepare environment
5656
run: util/prep-env.sh
5757
- name: set apt conf
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Compiling QCustomPlot as shared library:
2+
- Make sure the amalgamated QCustomPlot source files (qcustomplot.h/.cpp) are in the directory above sharedlib (two directories above the .pro files).
3+
- Run qmake; make; in the sharedlib-compilation directory. This will create two library versions: "qcustomplot" for release mode and "qcustomplotd" for debug mode.
4+
For example, on Unix this will create libqcustomplot.so and libqcustomplotd.so and some softlink files to those shared library files.
5+
On MS Windows it will create corresponding .dll files.
6+
7+
Compiling an application that uses the shared library:
8+
- Copy all created library/softlink files from the previous step to the sharedlib-usage directory
9+
- run qmake; make; in the sharedlib-usage directory. This will build the application.
10+
11+
Running the application:
12+
- Make sure the application executable can find the shared library files:
13+
On MS Windows it is sufficient to have the library .dll files in the same directory as the executable.
14+
On Unix you have at least two options: You can specify the current directory in the LD_LIBRARY_PATH variable (call in
15+
terminal: "export LD_LIBRARY_PATH=." before launching the application from the same terminal session). This is useful
16+
for testing if it works. The other option is to install the library files to one of the default locations for shared
17+
objects: /usr/local/lib or /usr/lib for example.
18+
- Launch the application.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Project to compile QCustomPlot as shared library (.so/.dll) from the amalgamated sources
3+
#
4+
5+
QT += core gui
6+
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
7+
8+
DEFINES += QCUSTOMPLOT_COMPILE_LIBRARY
9+
TEMPLATE = lib
10+
CONFIG += shared debug_and_release build_all
11+
VERSION = 1.3.2
12+
13+
TARGET = qcustomplot
14+
CONFIG(debug, debug|release) {
15+
TARGET = $$join(TARGET,,,d) # if compiling in debug mode, append a "d" to the library name
16+
QMAKE_TARGET_PRODUCT = "QCustomPlot (debug mode)"
17+
QMAKE_TARGET_DESCRIPTION = "Plotting library for Qt (debug mode)"
18+
} else {
19+
QMAKE_TARGET_PRODUCT = "QCustomPlot"
20+
QMAKE_TARGET_DESCRIPTION = "Plotting library for Qt"
21+
}
22+
QMAKE_TARGET_COMPANY = "www.qcustomplot.com"
23+
QMAKE_TARGET_COPYRIGHT = "Copyright (C) by Emanuel Eichhammer"
24+
25+
SOURCES += ../../qcustomplot.cpp
26+
HEADERS += ../../qcustomplot.h
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <QApplication>
2+
#include <QMainWindow>
3+
#include "../../qcustomplot.h"
4+
5+
int main(int argc, char *argv[])
6+
{
7+
QApplication a(argc, argv);
8+
QMainWindow window;
9+
10+
// setup customPlot as central widget of window:
11+
QCustomPlot customPlot;
12+
window.setCentralWidget(&customPlot);
13+
14+
// create plot (from quadratic plot example):
15+
QVector<double> x(101), y(101);
16+
for (int i=0; i<101; ++i)
17+
{
18+
x[i] = i/50.0 - 1;
19+
y[i] = x[i]*x[i];
20+
}
21+
customPlot.addGraph();
22+
customPlot.graph(0)->setData(x, y);
23+
customPlot.xAxis->setLabel("x");
24+
customPlot.yAxis->setLabel("y");
25+
customPlot.rescaleAxes();
26+
27+
window.setGeometry(100, 100, 500, 400);
28+
window.show();
29+
return a.exec();
30+
}
31+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Example project that uses QCustomPlot as a shared library
3+
#
4+
# The compiled shared library file(s) must be in the project directory.
5+
# On Unix, set LD_LIBRARY_PATH to "." before launching the compiled application
6+
# unless the library files are installed in one of the library locations (e.g. /usr/lib)
7+
#
8+
# Note that the qcustomplot.h header should not be added to the project file in the
9+
# HEADERS variable, but only included in your source files with #include.
10+
#
11+
12+
QT += core gui
13+
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
14+
15+
TARGET = sharedlib-usage
16+
TEMPLATE = app
17+
18+
# Tell the qcustomplot header that it will be used as library:
19+
DEFINES += QCUSTOMPLOT_USE_LIBRARY
20+
21+
# Link with debug version of qcustomplot if compiling in debug mode, else with release library:
22+
CONFIG(debug, release|debug) {
23+
win32:QCPLIB = qcustomplotd1
24+
else: QCPLIB = qcustomplotd
25+
} else {
26+
win32:QCPLIB = qcustomplot1
27+
else: QCPLIB = qcustomplot
28+
}
29+
LIBS += -L./ -l$$QCPLIB
30+
31+
SOURCES += main.cpp

0 commit comments

Comments
 (0)