Adding a window title with Qt5

112 views
Skip to first unread message

Tom Whitzer

unread,
Nov 7, 2017, 1:25:55 AM11/7/17
to Python Programming for Autodesk Maya
Hey Everyone,

Beginner question, I am trying to get better working with Qt, but it has been a while since I learned basics of using it. I am trying to create a simple window at the moment with a title. I have seen online that I should use QWidgets.setWindowTitle(), but Maya keeps telling me that module doesn't exist. I don't seem to see any modules that would change a window title in the Qt.py file. How would I go about creating a Title? 

Best,
Tom

Marcus Ottosson

unread,
Nov 7, 2017, 1:28:07 AM11/7/17
to python_in...@googlegroups.com

I think you misread QWidgets for QWidget, which means every instance of a QWidget has setWindowTitle().


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b9cd92d9-5cd3-4705-ac50-8ec181885091%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tom Whitzer

unread,
Nov 7, 2017, 1:37:59 AM11/7/17
to python_in...@googlegroups.com
Thank you! I am getting an error that QWidget is not defined. I am guessing I am initializing the window incorrectly. 

On Tue, Nov 7, 2017 at 1:28 AM, Marcus Ottosson <konstr...@gmail.com> wrote:

I think you misread QWidgets for QWidget, which means every instance of a QWidget has setWindowTitle().

On 7 November 2017 at 06:25, Tom Whitzer <tjwh...@gmail.com> wrote:
Hey Everyone,

Beginner question, I am trying to get better working with Qt, but it has been a while since I learned basics of using it. I am trying to create a simple window at the moment with a title. I have seen online that I should use QWidgets.setWindowTitle(), but Maya keeps telling me that module doesn't exist. I don't seem to see any modules that would change a window title in the Qt.py file. How would I go about creating a Title? 

Best,
Tom

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
------------------------------------
Tom Whitzer

Marcus Ottosson

unread,
Nov 7, 2017, 1:49:30 AM11/7/17
to python_in...@googlegroups.com

Have a look at this example.

class MyWindow(QtWidgets.QDialog):
  def __init__(self, parent=None):
    super(MyWindow, self).__init__(parent)
    self.setWindowTitle("My Window Title")

Where QDialog is subclassed from QWidget, and also has this member.


On 7 November 2017 at 06:37, Tom Whitzer <tjwh...@gmail.com> wrote:
Thank you! I am getting an error that QWidget is not defined. I am guessing I am initializing the window incorrectly. 
On Tue, Nov 7, 2017 at 1:28 AM, Marcus Ottosson <konstr...@gmail.com> wrote:

I think you misread QWidgets for QWidget, which means every instance of a QWidget has setWindowTitle().


On 7 November 2017 at 06:25, Tom Whitzer <tjwh...@gmail.com> wrote:
Hey Everyone,

Beginner question, I am trying to get better working with Qt, but it has been a while since I learned basics of using it. I am trying to create a simple window at the moment with a title. I have seen online that I should use QWidgets.setWindowTitle(), but Maya keeps telling me that module doesn't exist. I don't seem to see any modules that would change a window title in the Qt.py file. How would I go about creating a Title? 

Best,
Tom

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b9cd92d9-5cd3-4705-ac50-8ec181885091%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.



--
------------------------------------
Tom Whitzer

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Tom Whitzer

unread,
Nov 7, 2017, 2:00:21 AM11/7/17
to python_in...@googlegroups.com
​I get it! Thank you, I wasn't trying to use classes. I know that when I learned how to use Qt, I was told to use classes, but I forgot to do that this time around. You are great Marcus!​

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Marcus Ottosson

unread,
Nov 7, 2017, 2:02:24 AM11/7/17
to python_in...@googlegroups.com

No problem. :)

You can also this without subclassing.

my_window = QtWidgets.QDialog()
my_window.setWindowTitle("My Window Title")




--
------------------------------------
Tom Whitzer

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Tom Whitzer

unread,
Nov 7, 2017, 2:07:47 AM11/7/17
to python_in...@googlegroups.com
Great, thanks! I did notice that, but I think for what I am attempting to do, classes is the way to go. ​

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages