(Ah I've just seen that Thinkingcap has written, in two lines, what I have just used an entire paragraph for :P )..
Is this the full version of Cubase? (I'm not sure if the following is available in Cubase Artist/Elements)..
1) Once you have recorded your MIDI Piano Part, set the MIDI/Instrument Track from Musical Timebase to Linear Timebase (in the MIDI/Instrument track's Inspector, click on the "quarter-note" icon to change it into a "clock" icon).
(This has the result that Cubase's Tempo Track can now be modified without changing what you actually hear )
2) If you had the Tempo in the Transport Bar set to "Fixed", change it to "Track".
3) If necessary, drag your MIDI Part, such that the first downbeat corresponds with the appropriate downbeat in Cubase's Grid (in the simplest case, that would be, align the first played note with the start of a bar.. it is in fact a good idea, generally, to let Cubase have a couple of bars "breathing space" before the music starts anyways ;) )
There are now two methods available in Cubase (like Thinkingcap said ;) ) ..
(the first is maybe simpler, but the 2nd is probably more thorough, especially if the music isn't particularly rhythmic, with obvious downbeats).
Open the Piano track's MIDI Part in the Key Editor, select the Timewarp Tool, and working through from left to right, drag the bar lines, such that they correspond with the downbeats of your music (like I said, earlier, this will change Cubase's Grid to fit the music, without changing what is actually heard ).
4) Create a new MIDI track, routed to some percussive/metronome sound, put it into Record, and "tap" along to your recorded Piano track, playing, normally, quarter-notes, just as if you were "conducting" the music (it becomes quite easy to do this once you've gotten the hang of it, especially seeing as it was you who played the piano part in the first place. And, in any case, seeing as this "tapping" is just a regular MIDI track, you can edit it afterwards until you are satisfied that it fits your music nicely).
5) Put this "tapping" track into Linear Timebase also.
[EDIT] 5b) HughH has discovered a bug with the next two steps, if you have created your "tapping" from a combination of several tracks, or several Lanes on the same track..
If this is your case, then merge (glue) your tapping into a single track before proceeding! [/EDIT]
6) Select the MIDI Part that contains your "tapping", and set the Left and Right Locators to its boundaries.
7) Go to the MIDI Menu>Functions>"Merge Tempo from Tapping", and, in the dialog that opens, set "Tapping" to 1/4 (if that is what you had tapped ;) ), and checkmark the option "Begin at Bar Start".
That should be it ;) (You can now put your tracks back to Musical Timebase, if you wish, so you can now modify Cubase's tempo if desired, and the music will follow).
It's actually easier than it reads, especially after having done it a few times;). Good luck :).
Just to be completely exhaustive ( :oops: :) ) ..
Both those methods work with recorded Audio also, provided that you also, before doing any of the above, go into the Audio Pool, and switch off "Musical Mode" for each of the Audio clips.