Rotating a linear slider

Anyone know how to rotate a linear slider?

I know how to create a rotary slider but I would like to take a linear slider and physically rotate it so it is off axis. I have tried the drawlinearslider() function in the lookandfeel class but this does not seem to give the functionality I need, and also seems to not even work as a slider anyway.



Beautiful, thanks

Using it like so:

Which I assume it fine? It’s got the result anyway

By the way, looking at the settransform documentation, I see the following:
setTransform ( const AffineTransform & transform )

As I am fairly new to c++ i came to my solution above by hacking around till it worked, however the documentation confuses me as I would expect the & to be referring to the address of a variable, but don’t have a clue what it means in this context. Could you help me understand what a term like this inside the bracket tells me about how I should use it?


One of the more annoying syntactical things about C++, IMO… :slight_smile:

In C you can get an address by using the ampersand on a variable:

int a; 
int *b = &a; // points to the memory address of 'a'
int *c = nullptr; // points to nothing

(*b) = 1; // de-reference the pointer to set a value

That’s still the case in C++, however C++ introduced references… which are similar to pointers but may not be nullptr, NULL, etc:

int a;

// Create a reference back to 'a', does not need to take address of the variable
int &b = a;

int *c = nullptr; // points to nothing
int &d = nullptr; // will not compile, references must always be valid 

// References do not need de-referencing, you can treat a and b as the same underlying variable
b = 5;

In the specific example of setTransform(), the function is requiring that you pass in an AffineTransform object by const-reference.

As mentioned before a reference is similar to a pointer in that it will map to the same underlying variable in memory, but references cannot be nullptr. So here you can’t pass “nothing” (no object) to setTransform(): it will always require passing an AffineTransform object or the code won’t even compile.

The const in the argument simply means that setTransform() will not be changing the object that you give it. Member variables of the object will not be allowed to change, and any methods that the function calls on that transform object may only be const methods.

Gotcha, thanks for the help