All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
It is an established fact that Allah, the Exalted, is the Creator of all things; He says (what means): {Allah is the Creator of all things, and He is, over all things, Disposer of affairs.} [Quran 39:62] Nothing takes place in the universe except by His will and predestination; He says (what means): {Indeed, all things We created with predestination.} [Quran 54:49]
There is no harm in saying that Allah did this or created this or the like in general; however, it is not polite nor appropriate to attribute evil to Him. ʻAli ibn Abi Taalib, may Allah be pleased with him, narrated the supplication that the Prophet, sallallahu ‘alayhi wa sallam, used to recite when he got up for prayer as part of a long hadeeth: "...all goodness is in Your hands, and evil is not attributed to You..." [Muslim]
The meaning, according to scholars of "All goodness is in Your hands," is that whatever is good comes from Allah and cannot be attained except by His decree. "...And evil is not attributed to You," means that evil is not a means to draw closer to Allah and is not attributed to Him exclusively out of politeness. Although evil was created by Allah, it is not attributed to Him, and it is not used to draw closer to Him.
The Muslim should beware of attributing his actions to Allah for the purpose of justifying his sins. Allah, the Exalted, says (what means): {Those who associated with Allah will say, "If Allah had willed, we would not have associated (anything) and neither would our fathers, nor would we have prohibited anything." Likewise, did those before deny until they tasted Our punishment. Say, "Do you have any knowledge that you can produce for us? You follow not except assumption, and you are not but falsifying."} [Quran 6:148]
Shaykhul-Islam Ibn Taymiyyah wrote, "According to the consensus of the followers of all religions and those who have sound minds, no one has the right to make excuses for the sin which he has committed by referring to the divine decree and predestination. Verily, those who consider the divine decree and predestination an excuse for evil actions and injustice are contradicting themselves and following their sinful desires..." [Minhaaj As-Sunnah]
Allah knows best.