qt-designer

How to make a Qt Widget grow with the window size?

柔情痞子 提交于 2019-11-27 03:05:50
I want to have a small QFormLayout that grows to fill its parent widget. I created a new .ui file using the QWidget template in Qt Designer. I put a QFormLayout inside that 'window', then put some controls inside that QFormLayout . This all works reasonably well, but the QFormLayout always stays at the size I set in Qt Designer. I would like the QFormLayout to fill its parent widget and grow/shrink with it. How can I accomplish that? Jens In Designer, activate the centralWidget and assign a layout, e.g. horizontal or vertical layout. Then your QFormLayout will automatically resize. Always make

Understanding form layout mechanisms in Qt

你说的曾经没有我的故事 提交于 2019-11-27 02:57:58
Qt has a flexible and powerful layout mechanism to handle view of desktop application's windows. But it is so flexible, that it nearly cannot be understood, when something goes wrong and needs fine tuning. And so powerful, that it can beat anyone in their tries to overwhelm Qt's opinion of how form should look. So, can anyone explain, or provide articles, or source of Qt's positioning mechanisms? I'm trying to force the QLabel , QPushButton and QTableView , marked by trailing underscores in their names, be two times higher than QTextBrowser having verticalStretch = 1 below. How can I handle

C++ over Qt : Controlling transparency of Labels and Buttons

寵の児 提交于 2019-11-27 02:23:37
问题 Well, I was again trying my hands on a Linux GUI app on Qt Creator, I added couple of images in a Qt resource file of my project. And I tried to have a nice background in my main window and other windows and dialogs. I was using from the stylesheets option (no coding). I am unable to set the transparency level of labels and pushbuttons. Any ideas on how to do it from Qt creator GUI itself ??? !I am attaching a snap of how my application looks. 回答1: You can set transparency of QLabel or

Hand Coded GUI Versus Qt Designer GUI [closed]

半腔热情 提交于 2019-11-26 23:49:36
问题 I'm spending these holidays learning to write Qt applications. I was reading about Qt Designer just a few hours ago, which made me wonder : what do people writing real world applications in Qt use to design their GUIs? In fact, how do people design GUIs in general? I, for one, found that writing the code by hand was conceptually simpler than using Qt Designer, although for complex GUIs Designer might make sense. Large GUIs might be possible using Designer, but with time they might become very

Customising code of Qt designer widget?

痴心易碎 提交于 2019-11-26 23:13:23
I need to add some features to a graphics widget in a form I created using the Qt Designer. For example I would normally do something like this: class custom_gv(QGraphicsView): def __init__(self): super().__init__() def zoom(self): # custom code here But in this case the graphics view is a part of the window I made in Qt Designer. I know you can use the "promote to" feature in Qt designer but I don't know how to utilise that in code, especially considering that I use this method to use Qt Designer windows: from PyQt5.uic import loadUiType custom_window = loadUiType('ui.ui') class Window

PyQt5: How to install/run Qt Designer

孤者浪人 提交于 2019-11-26 22:53:16
问题 Feeling really stupid, right now, but the title says it all: How do you start the QtDesigner? I've installed PyQt5 via pip and I believe to have identified the directory it's been installed in as C:\Users\%username%\AppData\Local\Programs\Python\Python36\Lib\site-packages\PyQt5 Now what? There are a lot of .pyd files, some .dll's, too, but nothing executable (well, except a QtWebEngineProcess.exe in ...\site-packages\PyQt5\Qt\bin , but that doesn't sound like what I'm looking for. 回答1: The

Create a widget to embed into QMainWindow

怎甘沉沦 提交于 2019-11-26 22:27:05
问题 I have this task that I couldn't solve yet. Working with PyQt and Qt Creator. I want to embed a custom created widget created in QT Creator into another QMainWindow. 1) Steps I do: Create a Widget file in QT creator: 2) Save it as *.ui and apply this line to convert it to a *.py file: pyuic5 gen_settings.ui -o gen_settings.py 3) Open it and see that it starts with from PyQt5 import QtCore, QtGui, QtWidgets class Ui_gen_settings(object): def setupUi(self, gen_settings): gen_settings

Linking a qtDesigner .ui file to python/pyqt?

大城市里の小女人 提交于 2019-11-26 21:15:46
So if I go into QtDesigner and build a UI, it'll be saved as a .ui file. How can I make this as a python file or use this in python? Maxim Popravko Another way to use .ui in your code is: from PyQt4 import QtCore, QtGui, uic class MyWidget(QtGui.QWidget) ... #somewhere in constructor: uic.loadUi('MyWidget.ui', self) both approaches are good. Do not forget, that if you use Qt resource files (extremely useful) for icons and so on, you must compile it too: pyrcc4.exe -o ui/images_rc.py ui/images/images.qrc Note, when uic compiles interface, it adds 'import images_rc' at the end of .py file, so

PyQt: No error msg (traceback) on exit

别说谁变了你拦得住时间么 提交于 2019-11-26 21:05:09
My PyQt application no longer prints the error (stderr?) to the console. I use QtDesigner and import the UI like this: from PyQt5 import QtCore, QtGui, QtWidgets import sys from PyQt5.uic import loadUiType Ui_MainWindow, QMainWindow = loadUiType("test.ui") class Main(QMainWindow, Ui_MainWindow): """Main window""" def __init__(self,parent=None): super(Main, self).__init__(parent) self.setupUi(self) self.pushButton.clicked.connect(self.testfunc) def testfunc(self): print(9/0) if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) main = Main() main.show() sys.exit(app.exec_()) test.ui

Best way to display logs in pyqt?

时间秒杀一切 提交于 2019-11-26 17:41:45
问题 I am currently working on a GUI using qt designer. I am wondering how I should go about printing strings on the GUI that acts like a logger window. I am using pyqt5. 回答1: If you are using the Python logging module to can easily create a custom logging handler that passes the log messages through to a QPlainTextEdit instance (as described by Christopher). To do this you first subclass logging.Handler . In this __init__ we create the QPlainTextEdit that will contain the logs. The key bit here