Results 1 to 3 of 3

Thread: Compile error - Qwt and Qt Designer

  1. #1
    Join Date
    Mar 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Compile error - Qwt and Qt Designer

    I've installed qwt and can compile & run all the qwt examples
    in C:\qwt-5.0.2\examples. I use Eclipse with MinGW on Windows XP.

    When I compile the very simple program called qwt_designer
    (shown below), I get the following error.
    make: *** [release] Error 2 qwt_designer line 0
    make[1]: *** [release\qwt_designer.exe] Error 1 qwt_designer line 0


    I only have one push button and one qwt plot object in the .ui file.
    The project compiles and runs fine
    - if I remove the qwt plot object from the .ui file
    or
    - if I do not declare the slots (line 18 of qwt_designer.h)
    which seems very weird to me...

    main.cpp
    Qt Code:
    1. #include <QtGui>
    2. #include <QApplication>
    3.  
    4. #include "qwt_designer.h"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9. qwt_designer w;
    10. w.show();
    11. a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
    12. return a.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    qwt_designer.cpp
    Qt Code:
    1. #include "qwt_designer.h"
    2.  
    3. qwt_designer::qwt_designer(QWidget *parent)
    4. : QWidget(parent)
    5. {
    6. ui.setupUi(this);
    7. }
    8.  
    9. qwt_designer::~qwt_designer()
    10. {
    11.  
    12. }
    To copy to clipboard, switch view to plain text mode 

    qwt_designer.h
    Qt Code:
    1. #ifndef QWT_DESIGNER_H
    2. #define QWT_DESIGNER_H
    3.  
    4. #include <QtGui/QWidget>
    5. #include "ui_qwt_designer.h"
    6.  
    7. class QTcpSocket;
    8.  
    9.  
    10. class qwt_designer : public QWidget
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. qwt_designer(QWidget *parent = 0);
    16. ~qwt_designer();
    17.  
    18. public slots: // <-- No error if this line is commented out
    19. void on_myButton_pressed();
    20.  
    21. private:
    22. Ui::qwt_designerClass ui;
    23. };
    24.  
    25. #endif // QWT_DESIGNER_H
    To copy to clipboard, switch view to plain text mode 

    qwt_designer.pro
    Qt Code:
    1. include(qwt_tools.pri)
    2. TEMPLATE = app
    3. TARGET = qwt_designer
    4. QT += core \
    5. gui
    6. HEADERS += qwt_designer.h
    7. SOURCES += main.cpp \
    8. qwt_designer.cpp
    9. FORMS += qwt_designer.ui
    To copy to clipboard, switch view to plain text mode 

    qwt_tools.pri - taken from the .pri file in qwt example.
    Qt Code:
    1. QWT_ABS_PATH = C:/qwt-5.0.2
    2. include( $$QWT_ABS_PATH/qwtconfig.pri )
    3. TEMPLATE = app
    4. MOC_DIR = moc
    5. OBJECTS_DIR = obj
    6. INCLUDEPATH += $$QWT_ABS_PATH/src
    7. DEPENDPATH += $$QWT_ABS_PATH/src
    8. unix:LIBS += -L$$QWT_ABS_PATH/lib \
    9. -lqwt
    10. win32:QwtDll:DEFINES += $$QT_DLL \
    11. QWT_DLL
    12. contains(CONFIG, QwtDll) {
    13. win32-msvc:LIBS += $$QWT_ABS_PATH/lib/qwt5.lib
    14. win32-msvc.net:LIBS += $$QWT_ABS_PATH/lib/qwt5.lib
    15. win32-msvc2005:LIBS += $$QWT_ABS_PATH/lib/qwt5.lib
    16. win32-g++:LIBS += -L \
    17. $$QWT_ABS_PATH/lib \
    18. -lqwt
    19. }
    20. else {
    21. win32-msvc:LIBS += $$QWT_ABS_PATH/lib/qwt.lib
    22. win32-msvc.net:LIBS += $$QWT_ABS_PATH/lib/qwt.lib
    23. win32-msvc2005:LIBS += $$QWT_ABS_PATH/lib/qwt.lib
    24. win32-g++:LIBS += -L \
    25. $$QWT_ABS_PATH/lib \
    26. -lqwt
    27. }
    To copy to clipboard, switch view to plain text mode 

    I'd appreciate your help.

  2. #2
    Join Date
    Mar 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Compile error - Qwt and Qt Designer

    qmake & make from the Qt 4.3.3 Command prompt showed the following:

    Qt Code:
    1. obj/moc_qwt_designer.o(.text+0xb5):moc_qwt_designer.cpp: undefined reference to
    2. `qwt_designer::on_myButton_pressed()'
    3. collect2: ld returned 1 exit status
    4. mingw32-make[1]: *** [release\qwt_designer.exe] Error 1
    To copy to clipboard, switch view to plain text mode 

    Adding the following to qwt_desginer.cpp has fixed the problem.
    Qt Code:
    1. void qwt_designer::on_myButton_pressed()
    2. {
    3. ;
    4. }
    To copy to clipboard, switch view to plain text mode 
    It's interesting that the combination of "slots in the header file" and "the Qwt plot object in the .ui file" forced the implementation of the function on_myButton_pressed().

  3. #3
    Join Date
    Nov 2010
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Compile error - Qwt and Qt Designer

    I have the similar problem with yoshi too, but not quite the same. Here is my error message dumped out when I was compiling the similar simple program. Thought I did as yoshi said, the problem still exists. It seems like that the moc didn't work. How can I fix the problem?

    mingw32-make -f Makefile.Debug all
    mingw32-make[1]: Entering directory `C:/Users/owr/Desktop/Trash/qwt-6.0.0-rc4/examples/curvdemo2'
    compiling curvdemo2.cpp
    In file included from ..\..\src/qwt_scale_div.h:14,
    from ..\..\src/qwt_plot_seriesitem.h:15,
    from ..\..\src/qwt_plot_curve.h:14,
    from curvdemo2.h:2,
    from curvdemo2.cpp:6:
    ..\..\src/qwt_interval.h:270: warning: 'bool QwtInterval::isValid() const' redeclared without dllimport attribute after
    being referenced with dll linkage

    In file included from curvdemo2.cpp:6:
    curvdemo2.h:17: error: expected ':' before 'slots'
    curvdemo2.h:18: error: expected primary-expression before 'void'
    curvdemo2.h:18: error: ISO C++ forbids declaration of 'slots' with no type
    curvdemo2.h:18: error: expected ';' before 'void'
    curvdemo2.cpp:33: error: no 'void MainWin::show_a()' member function declared in class 'MainWin'
    mingw32-make[1]: *** [debug/curvdemo2.o] Error 1
    mingw32-make[1]: Leaving directory `C:/Users/owr/Desktop/Trash/qwt-6.0.0-rc4/examples/curvdemo2'
    mingw32-make: *** [debug-all] Error 2
    curvdemo2.h:17: error: expected ':' before 'slots'
    curvdemo2.h:18: error: expected primary-expression before 'void'
    curvdemo2.h:18: error: ISO C++ forbids declaration of 'slots' with no type
    curvdemo2.h:18: error: expected ';' before 'void'
    curvdemo2.cpp:33: error: no 'void MainWin::show_a()' member function declared in class 'MainWin'

    PS: There is nothing wrong when I did this under Linux...

Similar Threads

  1. compile time error porting Qt3 designer form to Qt4
    By ashukla in forum Qt Programming
    Replies: 3
    Last Post: 20th September 2007, 11:48
  2. Replies: 13
    Last Post: 15th December 2006, 11:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.