pyside

resizeEvent doesn't work if I use QUiLoader for QMainWindow

萝らか妹 提交于 2021-02-11 14:57:28
问题 I load main window from ui file: main_1.py from PySide import QtCore, QtGui, QtUiTools import sys class ControlMainWindow(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) loader = QtUiTools.QUiLoader() file = QtCore.QFile("lat.ui") file.open(QtCore.QFile.ReadOnly) self.ui = loader.load(file) file.close def show(self): self.ui.show() def resizeEvent(self, event): print event app = QtGui.QApplication(sys.argv) MW = ControlMainWindow() MW.show() sys

Prevent tab cycling with Ctrl+Tab by default with QTabWidget

帅比萌擦擦* 提交于 2021-02-10 23:48:06
问题 I have the following example code that makes a three tab layout (with buttons on the third tab). By default, I can Ctrl + Tab / Ctrl + Shift + Tab to cycle between the tabs. How do I disable this functionality? In my non-example code, this is not desired behaviour. from PyQt4 import QtGui import sys def main(): app = QtGui.QApplication(sys.argv) tabs = QtGui.QTabWidget() push_button1 = QtGui.QPushButton("QPushButton 1") push_button2 = QtGui.QPushButton("QPushButton 2") tab1 = QtGui.QWidget()

PySide: method is not executed in thread context if method is invoked via lambda

佐手、 提交于 2021-02-08 10:21:22
问题 I have a Worker object and use its method moveToThread to put it in a thread. Now i call its work method: If I invoke the method directly, it is executed in the thread its object is living in If I invoke the method using lambda, the method is executed in the main thread Example: from PySide.QtCore import * from PySide.QtGui import * import sys class Worker(QObject): def __init__(self): super().__init__() def work(self): print(self.thread().currentThread()) class Example(QWidget): def __init__

PySide switching widgets with events?

冷暖自知 提交于 2021-02-05 08:50:57
问题 I can't figure it. I want to be able to swap out QWidgets according to events like button clicks but I am missing something and I haven't been able to search out any example along the lines of the code below. What I want to do is click one of the top buttons and get the widget below to switch between either the QCalendar or QtextEdit. Where am I going wrong? Thanks! #!/usr/bin/python import sys from PySide import QtGui, QtCore class Example(QtGui.QWidget): def __init__(self): super(Example,

Ubuntu - PySide module not found for python2 but works fine for python3

房东的猫 提交于 2021-02-05 08:22:26
问题 I had PyQt4 running fine with python2 on Ubuntu 12.04. I then installed python-PySide. But the installation test would give me a module not found error. Then I installed python3-PySide and it works fine. So obviously something to do with my environment paths, but I'm not sure what I need to do. I'm guessing PySide is automatically checking if python3 exists and if it does then it'll use it regardless. I need PySide to work with python2.7 because of Qt4.8 compatibility issues. Any suggestions?

How to display a list of QPushButton?

北城余情 提交于 2021-02-04 21:08:04
问题 I am a qt noob and I am trying to build an application that needs to display the following: a list of e-mail (which I am displaying in column 1 of a grid layout with a QListWidget1 left list) a list of passwords (which I display in column 2 of grid layout in a QListWidget2 middle list) Now, I would like to display a list of button (1 for every element of the list) which is supposed to copy the password in the QListWidget2. Should I just loop in column 3 and add a push button for every row? Or

How to capture button click from customized QMessageBox?

穿精又带淫゛_ 提交于 2021-02-04 16:01:06
问题 How can I modify the code for the customized QMessageBox below in order to know whether the user clicked 'yes' or 'no'? from PySide import QtGui, QtCore # Create a somewhat regular QMessageBox msgBox = QtGui.QMessageBox( QtGui.QMessageBox.Question, "My title", "My text.", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No ) # Get the layout question_layout = msgBox.layout() # Additional widgets to add to the QMessageBox qlabel_workspace_project = QtGui.QLabel('Some random data window:') qtextedit

QtSingleApplication for PySide or PyQt

狂风中的少年 提交于 2021-02-04 15:43:47
问题 Is there a Python version of the C++ class QtSingleApplication from Qt Solutions? QtSingleApplication is used to make sure that there can never be more than one instance of an application running at the same time. 回答1: Here is my own implementation. It has been tested with Python 2.7 and PySide 1.1. It has essentially the same interface as the C++ version of QtSingleApplication. The main difference is that you must supply an application unique id to the constructor. (The C++ version by

PySide: Add images to tooltips

别说谁变了你拦得住时间么 提交于 2021-01-29 02:31:04
问题 I'm building a tool that lists files in a directory. When you hover over each file it shows a tooltip displaying the date and who made the file. I'd also like an image to accompany this data. Is it possible to insert an image into a tooltip? For each item in the QTreeView I'd like a specific image and text to popup. If it can't be done with tooltips are there other alternatives? from PySide import QtCore, QtGui from shiboken import wrapInstance import maya.OpenMayaUI as mui def get_parent():

QWizard: Change height/dimensions of title field

白昼怎懂夜的黑 提交于 2021-01-28 12:26:59
问题 I'm currently trying to implement a simple "First steps" Wizard for a Python/Qt application I'm working on. This is really easy to do with Designer, but as usual the devil lies in the details. My problem is that the 'Title' field is way too big for me (~50% of the available screen estate). Here is a screenshot, and there the *.ui-file. I've already had a look at all the QWizard/QWizardPage properties and couldn't find anything that referred to the size/styling of the 'Title' field. Is there