How do I load QMovie within QtDesigner? - python

I need to be load QMovie in QtDesigner. I noticed that a lot of classes are not accessible from QtDesigner. I usually design in QtDesigner and I just load the ui file directly in my code. This way I never had to worry about implementing the GUI itself in code.
Is there a way I can do this without having to edit my code ?
So in summation I want to add QMovie to a horizontal layout in my main window.

QMovie is not a widget, so it makes no sense to add it to as layout.
You probably want a QLabel, which has a setMovie method for dispalying animated images. But note that a QMovie cannot play videos - if you want that functionality, you will have to use a Phonon.VideoWidget, rather than a QLabel.

Related

Converting .ui to .py with pyuic5?

When I convert a .ui file in QtDesigner to a .py file, the format changes and it runs differently.
When I run it in QtDesigner it looks like a normal page but once I convert it to a .py file and run it, the edges are cut off and I cannot see half the buttons/labels. Even once I expand the screen that has opened the labels are cut off and only half visible.
Is there a way I can stop this from happening?
You firstly need to correctly set the layout and widgets inside them, in a way that the size of each object is guaranteed when moving to the code.
Try to watch this tutorial, I found it very useful!
Qt Designer - create application GUI (DESIGN APPLICATION LAYOUT) - part 02
And then you need to just import the .ui file as follows:
from PyQt5 import uic
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow,self).__init__()
uic.loadUi("NameofYourFile.ui",self)
self.show()

How make a custom QPushButton in PyQt5?

I need to add a big button which will start some process. I know that I can make QPushButton large enough, however, I wish it be something like that
What can you suggest?
use flat QPushButton with transparent icon.

Qt Designer and Frameless Window

I am currently creating a GUI for an application and I want to make it frameless and add the minimize and close buttons myself. What I want to achieve can be seen in this answer:
The window structure I want to achieve
Since the GUI structure that I have in mind is really complex I really need that I have to use Qt Designer. Is there a way to achieve what is done in the answer above in the Qt Designer?
One way to achieve this is to create your application window as usual in Qt Designer, load the .ui file in the python via uic.loadUi and add it to the layout of box.contentWidget() instead of the edit in the linked example.

How to create PySide widget in C/C++

I have a very complex custom widget derived from QWidget in PySide.
At first its paintEvent was taking more than 1 second to complete. Then I've implemented a lot of caching with QPixmap to each layer of the "image" that I'm drawing. Now my paintEvent finishes in about 90ms - which is really fine, but not enough.
I'm wondering if I can implement this custom widget in plain C or C++, and then use it as an abstract widget in PySide (like PySide does with all other available widgets).
I found here that in PyQt I could use sip for this. But I can't find a match for this in PySide.
Does any one know how to do that?

PyQt4 - Maximize window along with inside widgets

I have a main window and I want that when I maximize it the widgets inside it should automatically be resized ....
Is there any way I can do that ????
Yes. Use layout objects (such as QHBoxLayout or QGridLayout) to organize your widgets inside, and set the widgets' resize modes accordingly. Note that standard Qt-supplied widgets support resizing by default.
If you want to save you a lot of work, don't hand-code the ui. Use Qt Creator to create a ui file and then load this file dynamically using PyQt4.uic module. There is also a "static" approach that generates python code from Qt Creator ui files.

Categories