When running your first opencv project with CDE you may experience the “cannot connect to x server” error when calling code that requires the opencv imageview or UI elements.
To fix simply set DISPLAY in your projects environment variables, make sure a file in your project is selected then goto run-> run configurations -> environment and add a display variable like the following: