{"id":998,"date":"2016-10-08T03:07:59","date_gmt":"2016-10-08T01:07:59","guid":{"rendered":"http:\/\/hobbykeller.spdns.de\/?p=998"},"modified":"2016-10-09T21:26:18","modified_gmt":"2016-10-09T19:26:18","slug":"qt-designer-finding-header-files-in-project-subdirectories","status":"publish","type":"post","link":"https:\/\/hobbykeller.spdns.de\/?p=998","title":{"rendered":"Qt Designer &#8211; Finding header files in project subdirectories"},"content":{"rendered":"<p>In order to organize larger Qt projects, I usually create subdirectories to hold different &#8220;components&#8221; of the project. For instance, I like to extend Qt&#8217;s <code>QLineEdit<\/code> into my own <code>DateLine<\/code> class which is a <code>QLineEdit<\/code> with some additional bells &amp; whistels such as checking if a valid date has been entered. These little helper classes are held in a project subdirectory called &#8211; guess what&#8230; &#8211; Helpers. Whenever I ran a build, Qt complained that my class header could not be found (&#8220;<code>dateline.h: No such file or directory<\/code>&#8220;).<\/p>\n<p><!--more--><\/p>\n<p>Although the <code>#include<\/code> command in the relevant cpp source file is complete, the headers are correctly listed in the <code>HEADERS<\/code> section of the pro file and intellitype finds the correct paths, Qt Designer fails to apply the full path in its auto-generated ui_***.h files for the different UI elements.<\/p>\n<p>The only workaround I found so far was by manually completing the #include directives in each ui_***.h file where the compiler stopped. As there were quite a few helper classes and quite a few UI elements in my project and it had to be done after each fresh build, these were hours wasted in manual corrections.<\/p>\n<p>After searching around, I finally found the reason in <a href=\"http:\/\/stackoverflow.com\/questions\/22301464\/qt-cannot-open-include-file-subdir\" target=\"_blank\">this post on stackexchange<\/a>: In your pro file, you have to add your subdirectory to the INCLUDEPATH variable. So a simple additional line like<\/p>\n<pre class=\"lang:default decode:true\" title=\"Adding include subdirectories to Qt Designers project file\">INCLUDEPATH += Helpers<\/pre>\n<p>will do the trick.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In order to organize larger Qt projects, I usually create subdirectories to hold different &#8220;components&#8221; of the project. For instance, I like to extend Qt&#8217;s QLineEdit into my own DateLine<span class=\"more-button\"><a href=\"https:\/\/hobbykeller.spdns.de\/?p=998\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\">Qt Designer &#8211; Finding header files in project subdirectories<\/span><\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[210,209,208,211],"class_list":["post-998","post","type-post","status-publish","format-standard","hentry","category-linux","tag-header-files","tag-includepath","tag-qt-designer","tag-subdirectories"],"_links":{"self":[{"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=\/wp\/v2\/posts\/998","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=998"}],"version-history":[{"count":3,"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=\/wp\/v2\/posts\/998\/revisions"}],"predecessor-version":[{"id":1003,"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=\/wp\/v2\/posts\/998\/revisions\/1003"}],"wp:attachment":[{"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=998"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=998"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hobbykeller.spdns.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}