Results 1 to 15 of 15

Thread: qstring.h no such file or directory error!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qstring.h no such file or directory error!

    Is the class header on the list of HEADERS in .pro file ? Check if you have moc_pushbutton.cpp somewhere in the build directories. I think the header is not moc'ed, so you get undefined references, make sure its in the list of HEADERS and run qmake/make again.
    Btw. you don't have to use QObject:: for connections, pushbutton class is derived from QObject, so you can simply call connect(...).

  2. #2
    Join Date
    Jun 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qstring.h no such file or directory error!

    Quote Originally Posted by stampede View Post
    Is the class header on the list of HEADERS in .pro file ? Check if you have moc_pushbutton.cpp somewhere in the build directories. I think the header is not moc'ed, so you get undefined references, make sure its in the list of HEADERS and run qmake/make again.
    Btw. you don't have to use QObject:: for connections, pushbutton class is derived from QObject, so you can simply call connect(...).
    i am using code blocks IDE and i didn't find any .pro file in the project folder.so should i create a .pro file to get rid of the error??

  3. #3
    Join Date
    Jun 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qstring.h no such file or directory error!

    here is the main.cpp

    Qt Code:
    1. #include <QApplication>
    2. #include "pushbutton.h"
    3.  
    4. int main(int argc, char* argv[])
    5. {
    6. QApplication app(argc, argv);
    7. pushbutton *button = new pushbutton("Dont click me");
    8.  
    9. button->show();
    10. return app.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    here is the pushbutton.h

    Qt Code:
    1. #ifndef PUSHBUTTON_H_
    2. #define PUSHBUTTON_H_
    3.  
    4. #include <QPushButton>
    5.  
    6. class pushbutton : public QPushButton
    7. {
    8. Q_OBJECT
    9.  
    10. public:
    11. pushbutton(const QString& text, QWidget* parent = 0) : QPushButton(text, parent)
    12. {
    13. connect(this,SIGNAL(clicked()),this,SLOT(change()));
    14. }
    15.  
    16. public slots:
    17. void change()
    18. {
    19. if(this->text() == "Don't click me!")
    20. {
    21. setText("Click me!");
    22. return;
    23. }
    24. setText("Don't click me!");
    25. }
    26. };
    27. #endif
    To copy to clipboard, switch view to plain text mode 

    ok i did some research and this is what i did

    first i runned the qmake -project with folder source as my project folder like
    Qt Code:
    1. c:/document......../myproject>qmake -project
    To copy to clipboard, switch view to plain text mode 

    then i got .pro file which has following data
    Qt Code:
    1. ##Automatically generated by qmake (2.01a) Thu May 5 16:40:27 2011#####
    2.  
    3. TEMPLATE = app
    4. TARGET =
    5. DEPENDPATH += .
    6. INCLUDEPATH += .
    7.  
    8. # Input
    9. HEADERS += pushbutton.h
    10. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 

    but still after doing that i am getting error as
    Qt Code:
    1. obj\Debug\main.o||In function `pushbutton':|
    2. C:\Documents and Settings\t\My Documents\project\sample\pushbutton.h|11|undefined reference to `vtable for pushbutton'|
    3. C:\Documents and Settings\t\My Documents\project\sample\pushbutton.h|11|undefined reference to `vtable for pushbutton'|
    4. ||=== Build finished: 2 errors, 0 warnings ===|
    To copy to clipboard, switch view to plain text mode 

    i am using code blocks IDE.
    Now can you guys help me.where am i doing wrong?????

    i also did qmake -makefile and got few makefiles even that is not solving the problem.

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qstring.h no such file or directory error!

    I've never used codeblocks, maybe its generating it's own Makefiles. Leave the IDE build system for now, good that you try to use the tools by hand - this way you can learn a lot more than by clicking on the IDE gui buttons.
    Try to cleanup all Makefiles in your project directories, run qmake --project again, then qmake and make. Code looks ok, so I guess this is caused by some leftovers in build directories.

  5. #5
    Join Date
    Jun 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qstring.h no such file or directory error!

    Finally it works! if you just search all the threads i have started.you will see that all my threads where on signals and slots and now it works can't believe it!!!!!

    anyways i am really feeling bad that i couldn't make it work with code blocks(it would have been easier)

    anyways i have written a program that will do QMAKE -project,QMAKE & MAKE(when placed in the project file)(that's less burden!!!)

    so thanks to all the people who helped me THANKS!

Similar Threads

  1. Replies: 11
    Last Post: 1st February 2018, 04:27
  2. Replies: 3
    Last Post: 12th March 2015, 20:06
  3. Replies: 4
    Last Post: 9th May 2010, 16:18
  4. Replies: 4
    Last Post: 17th February 2010, 10: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
  •  
Qt is a trademark of The Qt Company.