How do I use Base Classes like setName and setIcon?



I’m new to Juce and to C++. I’m trying to build a very simple VST. My question is how do I use base classes. I’ve been at this for hours and hours and i’m getting no where. Every where I search seems to assume that I have years of C++ experience. I just want to know how to use base classes like setName and setIcon. Again I’ve been searching these forums and the rest of the internet for hours and I’ve gotten no where. I don’t know what this

“void DocumentWindow::setName(const String & newName)”

means. Where do I put the new name and where do I even put this code? I tried putting it like this

“void DocumentWindow::setName(const String & “My Example Name”)”

but that just leads to errors. I’ve tried copying the code exactly as is from other forum answers but that leads to more errors. And when I search for what a base class is or how to use base classes, It’s all vague or it’s 10 pages of text, or the tutorial is from 2008 in Hindi. I may just be slow or something so please explain like i’m in elementary school. Thank you


This is the code that I’m referring to. How do I make setName do what it’s supposed to do?

This file was auto-generated!

It contains the basic startup code for a JUCE application.

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
	mainWindow = new MainWindow(getApplicationName());
    // Add your application's initialisation code here..

void shutdown() override
	mainWindow = nullptr;
    // Add your application's shutdown code here..

void systemRequestedQuit() override
    // This is called when the app is being asked to quit: you can ignore this
    // request and let the app carry on running, or call quit() to allow the app to close.

void anotherInstanceStarted (const String& commandLine) override
    // When another instance of the app is launched while this one is running,
    // this method is invoked, and the commandLine parameter tells you what
    // the other instance's command-line arguments were.
class MainWindow : public DocumentWindow
	MainWindow(String name) : DocumentWindow(name,
		centreWithSize(1000, 500);
	void closeButtonPressed() override
	void DocumentWindow::setName(const String & "My Example Name")


Ok so I figured it out on my own.

setName(“My example name”);

is placed right under

		centreWithSize(1000, 500);
                setName("My example name");

like so. I don’t really understand it yet but it works.


Now my other question how do you set an icon from an image on your desktop? Do I just put


Obviously not but that’s where I’m at right now.


if you’re referring to this:

void DocumentWindow::setIcon	(	const Image & 	imageToUse	)	

you need to supply an instance of the Image class.
If your image is stored in a file on your desktop, then you need to use one of the image helper classes to load it:

static Image ImageFileFormat::loadFrom	(	const File & 	file	)	

You’ll then need to supply an instance of a File object to that function, most likely generated from the File::getSpecialLocation() function.

You would be wise to visit a site like and get through a bunch of that material there before continuing further with JUCE. It’ll clear up a lot of questions you have that come from just not knowing C++, regardless of JUCE.


I am wondering, what does DocumentWindow have to do with a VST plugin, though? The poster’s code seems to be from a standalone application, not a plugin project…


Thanks, that makes sense. I’ll continue my c++ lessons. The challenge with c++ for me is that almost everything I want to do requires me learning other topics and those topics require me learning even more topics. It feels like wanting to bake a cake but first you have to learn what the cake is made of and before that you have to learn how to read cake language and before that you have to learn chemistry etc. But hopefully it all starts to click eventually.


This code is not the code that I’m using for the VST. It’s just a test code for learning purposes. Right now I’m just learning the API so that once I’ve learned all the required info I can start coding the actual VST.


OK, but do note that plugin projects are quite different from standalone application projects. You would for example practically never use a DocumentWindow (or ResizableWindow or TopLevelWindow) in one of those.


Thanks, I didn’t realize that. I’m following a Youtube tutorial series right now and they’re going through the basics, although I wish I could just learn what’s necessary. Right now I can’t tell the difference between what I should learn and what I don’t need to spend time learning.


Just learn it all so you don’t write crappy code. That’s usually what happens when new devs try to take shortcuts in the learning process.

“I want to write omnisphere and I bet I can finish it in one week”

Newsflash: that ain’t how learning to code works nor is learning to write audio software that simple lol


I think, the best thing you can do to figure out how to do it right is to learn some C++ basics completely apart from JUCE.

Go and search the internet for some tutorials where you learn how to write a simple command line application without any GUI in C++. The product of such exercises might not seem and be any similar to an audio plugin or application but most probably the first exercises will be very focused on some core concepts of the language itself. This should help you to get a basic idea of ideas behind object oriented programming in general how to write and read C++ code.

When you reached that basic level go back to a JUCE example project and you will most likely understand a lot more of it and will be able to either answer questions like the one you asked yourself or at least you will be able to ask much more specific questions.

I think this describes the things needed at least to bake a simple VST cake quite good :wink:

However, this level of detailed knowledge is something you can reach later on step by step after having finished your first working plugin. You will get a lot of things working somehow with some medium deep knowledge, but at some point you’ll realize yourself what are reasons to go that step further, I promise you :wink: