0

I am trying to create unit testing for my project but struggle with costumn widgets. While compiling the test unit, ui_mainwindow.h cannot find my widget.h anymore. My project structure looks like this:

Project
    scr
        scr.pro
        scr.pri
        mainwindow.ui
        CostumnWidgets
            widget.h
    test
        test.pro

In Qt-Designer i refer to my widget with ./CostumnWidgets/widget.h

scr.pri

QT       += core gui
TEMPLATE = app
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

SOURCES += $$PWD/mainwindow.cpp \
    $$PWD/CostumnWidgets/widget.cpp

HEADERS  += $$PWD/mainwindow.h \
    $$PWD/CostumnWidgets/widget.h

FORMS    += $$PWD/mainwindow.ui

test.pro

TARGET = Test
include(../scr/scr.pri)

QT += widgets
QT += testlib

SOURCES += $$PWD/test.cpp

How can I solve that without making a copy of my CostumnWidget-folder to my test directory? Thank you!

honiahaka10
  • 772
  • 4
  • 9
  • 29

1 Answers1

1

Take a look here. There various solutions for this. Simplest is marked as an answer there.

Community
  • 1
  • 1
Max Pashkov
  • 404
  • 1
  • 3
  • 12
  • Thank you that works! Although the path has to be `../../framework` instead of `../../../framework`. Not sure whether that is wrong in the other question or just specific to my project structure. What I do not understand: I guess the path generated in `build\ui_mainwindow.h` is relative to the `*pro-file` and not to `ui_mainwindow.h` is sthat right? Otherwise I do not understand how it could find that file in first place. Also: When I only change the path in either the `*pri-file` or Qt-Designer, it always seems to take the "incorrect" path. How is it decided which path to use? – honiahaka10 Apr 28 '17 at 14:35