well the answer is yes....OK I mean
but I would go along to a bank or the place that you have selected to give you a mortgage and run it by them.
I imagine that you are wondering about applying and being turned down and this affecting your rating. But at the Bank they give you lots of chance to call it off before they press 'send'
altho it turns out that you pay the mortgage with the rent, you do need an alternative source of income (to cover the void periods) and basically you will be limited to three times your salary
and they will want a decent deposit.
and good luck