pyside

Set column width for QTreeWidget

一世执手 提交于 2019-12-22 05:04:52
问题 Is there any way to set column width for QTreeWidget from code? I want to chage default width of first column. I'm using PySide. 回答1: QHeaderView::resizeSection() should do the trick, in C++ it would look like this: myTreeWidget->headerView()->resizeSection(0 /*column index*/, 100 /*width*/); 回答2: For people looking for a C++ Qt solution (tested with 5.12): // Important to call setMinimumSectionSize because resizeSection wont work if your width is less than the minimum treeWidget->header()-

get the exact height of QTextDocument in pixels

爱⌒轻易说出口 提交于 2019-12-22 01:15:29
问题 I need to get the actual height of QTextDocument in order to be able to set the containing QPlainTextEdit to a minimum height (while keeping its width constant) so that it shows the whole content without the vertical scrollbar. I tried to follow this question (closed with with accepted answer) How do I determine the height of a QTextDocument? but it does not do what it promises. A piece of code: from PyQt5.QtWidgets import QApplication, QPlainTextEdit app = QApplication([]) w = QPlainTextEdit

PyQT Listen for SystemWide Key and mouse events

穿精又带淫゛_ 提交于 2019-12-22 01:06:39
问题 I'm trying to write an application that listens for systemwide key and mouse events matching certain patterns and responds to them. I plan on making the application run in the background. No it is not a keylogger, it is a legit application with a good intent. I'm planning to user PyQT or more likely PySide for this application. It's fairly simple to listen to events when an application window is focused, but how would I do it when there is no window at all? I'm specifically working on OS X,

What is the parent of createEditor in a QStyledItemDelegate (PySide/PyQt/Qt)?

橙三吉。 提交于 2019-12-21 21:19:45
问题 I have a QTreeView of a QStandardItemModel . I am painting/editing the data using a custom delegate. Within createEditor method, I use parent.window() to access the main window of the entire application (see below to link to some code from another question). Question: what is the parent of createEditor in the delegate? It is defined with the following parameters: def createEditor(self, parent, option, index) What is confusing is when QStyledItemDelegate is initialized, and I print type(parent

Crash on close and quit

纵然是瞬间 提交于 2019-12-21 20:39:30
问题 I have a PySide application that hosts a VLC MediaPlayer instance within a QWidget. When the application is closed via the QMainWindow's close event, or by using QApplication.quit(), the UI disappears and then I get a Windows dialog "python.exe has stopped working". The QApplication hosts a custom QMainWindow class, which contains a custom QWidget (which handles all the UI tasks, with QMainWindow handling messaging between threads - the app records keystrokes and writes output files in

PySide threading and http downloading

时光总嘲笑我的痴心妄想 提交于 2019-12-21 19:41:12
问题 I've had soooo much trouble getting this code to work properly!!!! It runs fine when I debug it step by step, but when running normally it just crashes. Initially I was using a QThread to update the ImagePreview pixmap, but after a whole day of crashes and pain, I changed course. Now it works, in the above scenario when using the debugger, but otherwise I'm stumped. Please help me! What's wrong with this code? Is there another approach I can use? I'm trying to constantly update the image

Unable to Launch Qt uic

我是研究僧i 提交于 2019-12-21 15:38:15
问题 I have installed Qt designer 4.8.2, Pyside, and Python 3.3. When I create a form with Qt designer I am not able to see the code when clicking on view code. The error message is:"Unable to launch C:\Qt\4.8.2\bin\uic". I have the pyuic under C:\Python33\Lib\site-packages\PyQt4\uic. Please help. 回答1: Although you can certainly use Qt Designer for creating UIs for PySide/PyQt, you should be aware that it is primarily a C++ tool - it doesn't have any built in support for Python. So the "View Code.

Recommended way for installing PySide on Ubuntu

会有一股神秘感。 提交于 2019-12-21 07:23:10
问题 What is the recommended way of setting up PySide for development in Ubuntu? sudo apt-get install python3-pyside ? sudo pip install pyside ? sudo easy_install pyside ? 回答1: All your options will work. It depends what you are trying to achieve with it and how portable it should be. What usually "just" works without problems is to create a virtualenv first: apt-get -f install python-virtualenv virtualenv ~/mypython2.7 With that you can simply use easy_install as recommended to install PySide in

Styling with classes in Pyside + Python

有些话、适合烂在心里 提交于 2019-12-21 05:09:54
问题 How can I better style this app using classes rather than redefining the same styles for every label that should look the same. It makes it a pain to change a style because I then have to go through every label that is suppose to look the same and paste the code to match. #!/usr/bin/python # -*- coding: utf-8 -*- import sys from PySide import QtGui, QtCore class Example(QtGui.QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): #Add all GUI Elements to

QSettings(): How to save to current working directory

安稳与你 提交于 2019-12-21 04:19:16
问题 For an app that can be run directly from a flash/pen/usb/jump/thumb drive, for portability in moving from one machine to another it can make sense for user settings to be stored on the memory stick in the same directory that the program is being run from (rather than Windows/Mac/Linux user or system dirs per machine). QSettings() is handy, however, can it be told to use the current working directory? Here's a little example program that keeps its screen position from run to run using