Results 1 to 2 of 2

Thread: linker problem for qt5 - qt4 runs ok -> undefined reference to `QWidget::styleChange

  1. #1
    Join Date
    Jul 2008
    Location
    EU , Poland, Zabrze
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default linker problem for qt5 - qt4 runs ok -> undefined reference to `QWidget::styleChange

    I get the following error when I try to use qt5 for compiling - qt4 works fine. I always make sure to do make clean before make

    Qt Code:
    1. g++ -Wl,-O1 -o raport main.o mainwindow.o qcgaugewidget.o qcustomplot.o qrc_res_file.o moc_mainwindow.o moc_qcgaugewidget.o moc_qcustomplot.o -lQt5OpenGL -L/usr/lib64 -lQt5PrintSupport -lQt5Widgets -lQt5Gui -lQt5Network -lQt5Sql -lQt5Xml -lQt5Core -lGL -lpthread
    2. moc_mainwindow.o:(.data.rel.ro._ZTV10MainWindow[_ZTV10MainWindow]+0x188): undefined reference to `QWidget::styleChange(QStyle&)'
    3. moc_mainwindow.o:(.data.rel.ro._ZTV10MainWindow[_ZTV10MainWindow]+0x190): undefined reference to `QWidget::enabledChange(bool)'
    4. moc_mainwindow.o:(.data.rel.ro._ZTV10MainWindow[_ZTV10MainWindow]+0x198): undefined reference to `QWidget::paletteChange(QPalette const&)'
    5. moc_mainwindow.o:(.data.rel.ro._ZTV10MainWindow[_ZTV10MainWindow]+0x1a0): undefined reference to `QWidget::fontChange(QFont const&)'
    6. moc_mainwindow.o:(.data.rel.ro._ZTV10MainWindow[_ZTV10MainWindow]+0x1a8): undefined reference to `QWidget::windowActivationChange(bool)'
    7. moc_mainwindow.o:(.data.rel.ro._ZTV10MainWindow[_ZTV10MainWindow]+0x1b0): undefined reference to `QWidget::languageChange()'
    8. moc_mainwindow.o:(.data.rel.ro._ZTV11ProgressBar[_ZTV11ProgressBar]+0x188): undefined reference to `QWidget::styleChange(QStyle&)'
    9. moc_mainwindow.o:(.data.rel.ro._ZTV11ProgressBar[_ZTV11ProgressBar]+0x190): undefined reference to `QWidget::enabledChange(bool)'
    10. moc_mainwindow.o:(.data.rel.ro._ZTV11ProgressBar[_ZTV11ProgressBar]+0x198): undefined reference to `QWidget::paletteChange(QPalette const&)'
    11. moc_mainwindow.o:(.data.rel.ro._ZTV11ProgressBar[_ZTV11ProgressBar]+0x1a0): undefined reference to `QWidget::fontChange(QFont const&)'
    12. moc_mainwindow.o:(.data.rel.ro._ZTV11ProgressBar[_ZTV11ProgressBar]+0x1a8): undefined reference to `QWidget::windowActivationChange(bool)'
    13. moc_mainwindow.o:(.data.rel.ro._ZTV11ProgressBar[_ZTV11ProgressBar]+0x1b0): undefined reference to `QWidget::languageChange()'
    To copy to clipboard, switch view to plain text mode 

    I have checked what other threads suggested
    my .pro looks like this
    Qt Code:
    1. # -------------------------------------------------
    2. # Project created by QtCreator 2009-12-02T13:24:40
    3. # -------------------------------------------------
    4. QT += network \
    5. opengl \
    6. sql \
    7. xml \
    8. gui
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10. greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
    11.  
    12. TARGET = raport
    13. TEMPLATE = app
    14. SOURCES += main.cpp \
    15. mainwindow.cpp \
    16. qcgaugewidget.cpp \
    17. qcustomplot.cpp
    18. HEADERS += mainwindow.h \
    19. qcgaugewidget.h \
    20. qcustomplot.h
    21. FORMS += mainwindow.ui
    22. CONFIG += static
    23.  
    24. RESOURCES += \
    25. res_file.qrc
    To copy to clipboard, switch view to plain text mode 

    and all header files mentioned in .pro contain
    #include <QWidget>

  2. #2
    Join Date
    Jul 2008
    Location
    EU , Poland, Zabrze
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Smile Re: linker problem for qt5 - qt4 runs ok -> undefined reference to `QWidget::styleCh

    I accidentally found the source of problem
    in my mainwindow.h I had

    #include <QtGui/QMainWindow>


    changing it to
    #include <QMainWindow>

    solved the problem

Similar Threads

  1. Replies: 8
    Last Post: 14th July 2015, 16:56
  2. Replies: 2
    Last Post: 6th March 2012, 11:47
  3. Undefined reference problem
    By deepa in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2011, 12:48
  4. Problem: Undefined reference
    By stiank81 in forum Qt Programming
    Replies: 4
    Last Post: 16th February 2006, 15:17
  5. Replies: 5
    Last Post: 15th February 2006, 00:43

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.