I am using PySide2 for GUI. I have a "Rename Project" QAction. The function must be like this:

  1. set enable to false if tab name is "*Untitled" or file is unsaved.
  2. set enable to True if file is loaded.
    How to do this?
  3. Whenever switching to tab, these functions should be observed.

I could be wrong but it sounds like you are asking for code. But let's dive in.

To look at this I read this link: https://wiki.qt.io/Qt_for_Python#What_does_Qt_for_Python_look_like.3F

For item 1 you would craft code to test the tab name then set the object's enable property. Or a flag in the object's handler.

So, is the problem finding the object properties or testing for the condition?

I created a method that would look for tab name like this:

def enable_rename():
    if tab_name != '*Untitled":

I put this to my initialization part. But this is not working.

That code doesn't look correct to me. I would have expected to read something about PySide.QtGui.QTabBar.tabText(index).
Documentation appears to be at https://srinikom.github.io/pyside-docs/PySide/QtGui/QTabBar.html

This leads me to think you are just beginning to use Pyside which is all well and good but if you are looking for coders you'll have to put up the project requirements and what the pay for the job is.

Read https://www.daniweb.com/programming/threads/435023/read-this-before-posting-a-question to cover all the other areas of a good question.