[SOLVED] objectName() == ""

  • It came up in another discussion, but I thought it best to make into a new item.

    Which widgets have no name? I know that I always give proper names to widgets on the form so where do these come from?

  • Widgets that are created from code by default have no name. Widgets that are created from .ui files by default do have a name (a name is autogenerated for every widget you add to the form).

  • I thought that the names came only from the ui-file, not from the cpp code. It seems I was wrong about that.

  • A .ui file is also compiled into cpp code, so that doesn't make sense. QObject has a method setObjectName. In pre-Qt 4 versions, the object name was even a constructor argument.

  • In the constructor code from the ui file the automatic code includes setting the ObjectName!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.