Grafik Darstellung mit Qt

Alles rund um die Programmierung mit Qt
franzf
Beiträge: 3114
Registriert: 31. Mai 2006 11:15

Beitrag von franzf »

WAS klappt denn nicht?
Bitte mit Fehlermeldung.
agbamobl
Beiträge: 18
Registriert: 12. März 2009 16:16

Beitrag von agbamobl »

ich weiss ich nicht wie ich die dartellung sehen kann. Ich habe qmake-qt4 und make getippt. aber bei make. eigentlich ich weiss nicht welche befehle soll ich tippen und zu kompilieren.
sorry aber ich bin total neu dabei
franzf
Beiträge: 3114
Registriert: 31. Mai 2006 11:15

Beitrag von franzf »

Code: Alles auswählen

$ cd /pfad/zu/qwt-5.2.0/examples/simple_plot
$ qmake-qt4
# bei mir heißt es nur "qmake" aber das ist wohl unterschiedlich...
$ ../bin/simple
# das hat jetzt tatsächlich den Plot aufgemacht :)
Du kannst auch alle examples auf einmal bauen, wenn du nur bis "qwt-5.2.0/examples" gehst und da eben qmake und make laufen lässt.

Grüße
Franz
agbamobl
Beiträge: 18
Registriert: 12. März 2009 16:16

Beitrag von agbamobl »

danke für deine Hilfe
ich habe jetzt diese Meldung

Code: Alles auswählen

./simple: error while loading shared libraries: libqwt.so.5: cannot open shared object file: No such file or directory
[/code]
franzf
Beiträge: 3114
Registriert: 31. Mai 2006 11:15

Beitrag von franzf »

Dann hast du dein qwt in einen ungewöhnlichen Pfad installiert, der nicht in $LDPATH vorhanden ist, oder aber ein "make install" vergessen.
Bei mir schaut das so aus:

Code: Alles auswählen

 ldd simple | grep qwt
        libqwt.so.5 => /usr/lib/libqwt.so.5 (0x00007ff8bba32000)

Code: Alles auswählen

echo $LDPATH
/usr/local/lib://usr/lib32/opengl/nvidia/lib://usr/lib64/opengl/nvidia/lib:/lib:/usr/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib32:/usr/lib32:/usr/local/lib32:/usr/x86_64-pc-linux-gnu/lib:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/32:/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2:/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/32:/usr/lib64/nspr:/usr/lib64/nss:/opt/blackdown-jdk-1.4.2.03/jre/lib/amd64/:/opt/blackdown-jdk-1.4.2.03/jre/lib/amd64/native_threads/:/opt/blackdown-jdk-1.4.2.03/jre/lib/amd64/classic/:/opt/blackdown-jdk-1.4.2.03/jre/lib/amd64/server/:/usr/lib64/qca1:/usr/lib64/qca2:/usr/lib/qt4:/usr/lib64/qt4:/usr/lib32/qt4:/usr/qt/3/lib:/usr/qt/3/lib64:/usr/qt/3/lib32:/usr/games/lib:/usr/games/lib64:/usr/games/lib32:/usr/lib64/fltk-1.1:/usr/lib32/libstdc++-v3/
Wohin und wie hast du dein qwt installiert?
agbamobl
Beiträge: 18
Registriert: 12. März 2009 16:16

Beitrag von agbamobl »

ich bekomme so was:
gruppe2@debian:~/qwt/qwt-5.2.0/examples/bin$ ldd simple |grep qwt
libqwt.so.5 => not found
ich hatte nach meine kompilation diese befehl getippt:
export LD_LIBRARY_PATH=/home/gruppe2/qwt/qwt-5.2.0/lib
ist das nicht korekt?
agbamobl
Beiträge: 18
Registriert: 12. März 2009 16:16

Beitrag von agbamobl »

danke ich habe nochmals den pfad gegeben und es funktioniert .

Aber ich habe nur eine Frage wenn ich etwas programmiere, werde ich immer folgendes machen

Code: Alles auswählen

 qmake-qt4
           make
und dann in den Ordner bin gehen um die ausführbare datei finden?
franzf
Beiträge: 3114
Registriert: 31. Mai 2006 11:15

Beitrag von franzf »

Naja, kommt drauf an. Wenn du die Qt-Project-files verwendest, dann ja (wenn es schon existiert, wenn nicht musst du das erstellen).

Aber prinzipiell (jetzt wo du in den Startlöchern stehst und alles installiert hast :) ) fang für den Anfang mal mit diesem schönen Tutorial an:
http://doc.qtsoftware.com/4.4/tutorials-tutorial.html
Da ist alles dabei.

Grüße
Franz
agbamobl
Beiträge: 18
Registriert: 12. März 2009 16:16

Beitrag von agbamobl »

danke, aber ich meine wie ich programm kompilieren kann
beispiel

Code: Alles auswählen

#include <qapplication.h>
#include <qwt_plot.h>
#include <qwt_data.h>

#include <cmath>

class Plot : public QwtPlot
{
  // simple class to demonstrate Qwt Plots

  static  int const NPOINTS = 150;
  double x[NPOINTS], ysin[NPOINTS], ycos[NPOINTS];
public:
  Plot();
  void getData( );
};

Plot::Plot()
{
    setTitle("A Simple QwtPlot Demonstration");
    setAutoLegend(TRUE); // We want a legend
    setLegendPosition(QwtPlot::Right);

    // Set axis titles
    setAxisTitle(xBottom, "x -->");
    setAxisTitle(yLeft, "y -->");

    // produce some data
    getData();

    // Insert new curve
    long cSin = insertCurve("y = sin(x)");

    // Set curve styles
    setCurvePen(cSin, QPen(Qt::red));
    setCurveData(cSin, x, ysin, NPOINTS );

    long cCos = insertCurve("y = cos(x)");
    setCurveStyle(cCos, QwtCurve::NoCurve);

    // use symbol for plot
    const QColor &c = Qt::blue;
    setCurveSymbol(cCos, QwtSymbol(QwtSymbol::XCross,
        QBrush(c), QPen(c), QSize(5, 5)) );
    setCurveData(cCos, x, ycos, NPOINTS );

    replot();
}

void Plot::getData()
  // produce some dummy data
{
  for ( int i=0; i<NPOINTS; i++ ) {
    x[i] = 0.1*i;
    ysin[i] = sin(x[i]);
    ycos[i] = cos(x[i]);
  }
}

int main(int argc, char **argv)
{
    QApplication a(argc, argv);

    Plot plot;
    a.setMainWidget(&plot);
    plot.resize(500,300);
    plot.show();
    return a.exec();


ich habe versucht zu kompilieren und hat sowas bekommen:

Code: Alles auswählen

debian:/home/gruppe2/prog/qwttest# qmake-qt4 -project
debian:/home/gruppe2/prog/qwttest# qmake
debian:/home/gruppe2/prog/qwttest# make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o qwttest.o qwttest.cpp
qwttest.cpp:2:22: error: qwt_plot.h: No such file or directory
qwttest.cpp:3:22: error: qwt_data.h: No such file or directory
qwttest.cpp:8: error: expected class-name before ‘{’ token
qwttest.cpp: In constructor ‘Plot::Plot()’:
qwttest.cpp:20: error: ‘setTitle’ was not declared in this scope
qwttest.cpp:21: error: ‘setAutoLegend’ was not declared in this scope
qwttest.cpp:22: error: ‘QwtPlot’ has not been declared
qwttest.cpp:22: error: ‘setLegendPosition’ was not declared in this scope
qwttest.cpp:25: error: ‘xBottom’ was not declared in this scope
qwttest.cpp:25: error: ‘setAxisTitle’ was not declared in this scope
qwttest.cpp:26: error: ‘yLeft’ was not declared in this scope
qwttest.cpp:32: error: ‘insertCurve’ was not declared in this scope
qwttest.cpp:35: error: invalid use of incomplete type ‘struct QPen’
/usr/include/qt4/QtGui/qwindowdefs.h:69: error: forward declaration of ‘struct QPen’
qwttest.cpp:35: error: ‘setCurvePen’ was not declared in this scope
qwttest.cpp:36: error: ‘setCurveData’ was not declared in this scope
qwttest.cpp:39: error: ‘QwtCurve’ has not been declared
qwttest.cpp:39: error: ‘setCurveStyle’ was not declared in this scope
qwttest.cpp:42: error: invalid initialization of reference of type ‘const QColor&’ from expression of type ‘Qt::GlobalColor’
qwttest.cpp:43: error: ‘QwtSymbol’ has not been declared
qwttest.cpp:44: error: invalid use of incomplete type ‘struct QBrush’
/usr/include/qt4/QtGui/qwindowdefs.h:70: error: forward declaration of ‘struct QBrush’
qwttest.cpp:44: error: invalid use of incomplete type ‘struct QPen’
/usr/include/qt4/QtGui/qwindowdefs.h:69: error: forward declaration of ‘struct QPen’
qwttest.cpp:44: error: ‘QwtSymbol’ was not declared in this scope
qwttest.cpp:44: error: ‘setCurveSymbol’ was not declared in this scope
qwttest.cpp:47: error: ‘replot’ was not declared in this scope
qwttest.cpp: In function ‘int main(int, char**)’:
qwttest.cpp:65: error: ‘class QApplication’ has no member named ‘setMainWidget’
qwttest.cpp:66: error: ‘class Plot’ has no member named ‘resize’
qwttest.cpp:67: error: ‘class Plot’ has no member named ‘show’
qwttest.cpp:68: error: expected `}' at end of input
make: *** [qwttest.o] Error 1
franzf
Beiträge: 3114
Registriert: 31. Mai 2006 11:15

Beitrag von franzf »

Dir fehlern Header und libs für QWT. Der Fehler sagt ja dass er <qwt_plot.h> nicht finden kann, die nachfolgenden Fehler sagen dass Typen fehlen - genau die aus qwt_plot.h>.

Hier ein Link:
http://doc.qtsoftware.com/4.5/qmake-pro ... -libraries
INCLUDEPATH und LIBS ist das für dich interessante.
Les dir vllt. mal mehr von der Doku zu QMake durch, wenn du QMake verwenden willst, was für einen Qt-Programmierer nahe liegt, wenngleich für weitergehende Sachen auch cmake recht interessant ist. Bleib aber lieber erstmal bei qmake :)
Antworten