Failing to display dummy image


#1

Hello, I'm trying to display a dummy image, but I'm failing to do it.  A few std::couts indicated the image loaded correctly but I cannot view it !  All those setVisible() stuff is verbose, but I don't see a missing one, so I don't thing it's that's the issue eiher.  Can you help me ?  Thank you !

The project is small, here the code below :

Main.cpp :

#include "../JuceLibraryCode/JuceHeader.h"
#include "MainWindow.hpp"
using namespace juce;
 
class StrokerApplication  : public JUCEApplication
{
public:
    StrokerApplication() {}
 
    const String getApplicationName() override       { return ProjectInfo::projectName; }
    const String getApplicationVersion() override    { return ProjectInfo::versionString; }
    bool moreThanOneInstanceAllowed() override       { return true; }
 
    void initialise (const String& commandLine) override
    {
        applicationWindow = new MainWindow();
    }
 
    void shutdown() override
    {
    }
 
    void systemRequestedQuit() override
    {
        quit();
    }
 
    void anotherInstanceStarted (const String& commandLine) override
    {
    }
private:
    ScopedPointer<MainWindow> applicationWindow;
};
 
START_JUCE_APPLICATION (StrokerApplication)

MainWindow.hpp :

#ifndef HEADER_MainWindow
#define HEADER_MainWindow

#include "../JuceLibraryCode/JuceHeader.h"
#include "Canvas.hpp"

class MainWindow : public DocumentWindow
{
public:
    MainWindow();

    void closeButtonPressed();

private:
    ScopedPointer<ImageCanvas> backgroundCanvas;
    //JUCE_DECLARE_NON_COPYABLE(MainWindow);
};

#endif

MainWindow.cpp :

#include "MainWindow.hpp"

MainWindow::MainWindow()
    : DocumentWindow( "Stroker", Colours::grey, DocumentWindow::allButtons )
    , backgroundCanvas(new ImageCanvas())
{
    setContentOwned(backgroundCanvas, false);
    setVisible(true);
}

void MainWindow::closeButtonPressed()
{
    JUCEApplication::getInstance()->systemRequestedQuit();
}

Canvas.hpp :

#ifndef HEADER_Canvas
#define HEADER_Canvas

#include "../JuceLibraryCode/JuceHeader.h"

class ImageCanvas : public Component
{
public:
    ImageCanvas();
private:
    ImageComponent dummyImage;
};

#endif

Canvas.cpp :

#include "Canvas.hpp"
#include <iostream>

ImageCanvas::ImageCanvas()
    : Component(), dummyImage()
{
    Image dummy = ImageCache::getFromFile( File("/home/denethor/Pictures/q.png") );
    dummyImage.setImage( dummy );
    addAndMakeVisible( dummyImage );
}

 


#2

You don't seem to have given your ImageComponent a position or size.


#3

Oh.  Qt's bad habits.