Great tutorials! Thank you! One thing I encountered was that the text cursor has to be placed before the search string in the 'textedit' widget. Otherwise, the search function will not find the search term. This is taken care of when loading text from file, but not when manually entering text. (This applies to the previous 'textedit' tutorials in this series as well.)
@imadetheuniverse4fun2 жыл бұрын
Hey Alan, any advice on how to get a stylesheet to apply to a custom subclass of a QtWidgets class? Examples: class MyButton(QPushButton): def __init__(self): super().__init__() stylesheet = """ MyButton { background: red; } """ setting the above as the stylesheet doesnt work, whereas if I change the name from MyButton to QPushButton, it does work. But of course then all QPushButtons will have that style, which is not wanted.
@alexp44484 жыл бұрын
This was a great video. Good job explaining everything. I am trying to understand how the styles are actually implemented though, like you referenced. I think QPainter is involved but the C++ docs are not very helpful on this topic. thanks
@mohamed-tm8kr2 жыл бұрын
how do i add white text outlined with black borders so it can appear on any surface with QT designer? is there a code to add to the stylesheet in order for this to show up?
@danmusser52803 жыл бұрын
Thanks for the great video! A question, if I want the menu bar to have a different color background than the text-editor window, I tried creating an object name on the "self.menuBar" object and then in my variables at the bottom I assigned the color that I wanted it to be. It threw up an error that said, "menubar() takes no keyword arguments". I assume the menu bar isn't a widget, and maybe it's only possible to change widgets independently? Is there a way around this? By the way I just purchased your book, (it should come tomorrow), do you go into greater depth on this in the book?
@alandmoorecodes35853 жыл бұрын
Menu bars are a little different in that (by default) they aren't actual Qt widgets but a wrapper around the Operating System/Desktop environment's built-in menu functionality. This allows, for example, your menus to be in the global menu area on macOS. You should be able to set a name using the setObjectName method, but if it still won't accept styling, try calling the setNativeWidget(False) method to make Qt create the menu instead of using the built-in API.
@danmusser52803 жыл бұрын
Alan another quick question: If I have multiple layouts on my GUI app, (multiple layouts on the same window), is there something besides stylesheets that would allow me to customize the background color of each layout? Maybe even put a border around the layouts? This series is awesome I sure appreciate it, (I did purchase the book, but I couldn't find anything about this in it). Thanks!
@alandmoorecodes35853 жыл бұрын
Easiest way to get a border is to build each layout on a QFrame, then play with the FrameStyle and lineWidth properties. You can customize the background color of a widget by creating a custom QPalette object and assigning it to the widget's palette property. Now if you want your color changes to affect every descendant widget on the frame as well, that's a bigger deal. I would say you'd want to sub-class QFrame or QWidget and maybe create a custom addChildWidget method that overrides the child widget's palette before adding it to the layout. Or, of course, you could use stylesheets. :-)
@mhagen Жыл бұрын
Hello Alan, I've got your book. Very helpful. But stylesheets are not going well for me. The problem is that they are hard to debug. If you mess up the syntax on a command, there is no Python error. Qt just refuses to render that command and the Python routine moves on to the next object. What techniques do you use to debug QT stylesheets? Is there a "verbose" or "logging" mode that I can turn on to see where things go sideways? This might be a nice topic for a video.
@justoneofthepeople75854 жыл бұрын
I need help please😢 with this problem. I am learning from your book GUI python. I have this when I try to convert the ui file into python file. 'pyuic5.bat' is not recognized as an internal or external command, operable program or batch file. i am using pycharm. what should I do I have tried for 4 days with no solution.😔