FAQ Database Discussion Community


why signal emitting in QDialog can not invoke the connected slot in QThread?

python,pyside
This is my code: from PySide import QtCore, QtGui import sys import time class TestThread(QtCore.QThread): def __init__(self): self.finished_flag = False super(TestThread, self).__init__() def finished(self): print('==========finished function is invoked!=======================') self.finished_flag = True def run(self): while(True): print('thread is running...') time.sleep(1) if self.finished_flag: print('thread exist!') break class TestDialog(QtGui.QDialog): ForceTermimateSignal = QtCore.Signal() def done(self,...

How to install ipython qtconsole with pyenv (Python version 3.4.2)

python,python-3.x,ipython,pyside
I am using Ubuntu 14.04. I installed pyenv and then installed Python 3.4.2 under pyenv. Then I switched to version 3.4.2: $ pyenv global 3.4.2 Now I would like to install ipython and the qtconsole: $ pip install ipython $ ipython3 qtconsole & This gives an error message (traceback not...

How to only emit one directoryChanged signal with QFileSystemWatcher

python,pyqt,pyside,qfilesystemwatcher
Here's the basic premise of my application: I've established a QFileSystemWatcher to watch a directory. Path = [r'C:\Users\user\Documents\Images'] DirectoryWatcher = QtCore.QFileSystemWatcher(Path) DirectoryWatcher.directoryChanged.connect(showImages.UpdateImages) I've used QFileSystemWatcher in the past, and it's always worked perfectly (for both directory and file changes). The application will display a slideshow of the images in the...

QSqlRelationalTableModel with QSqlRelationalDelegate not working behind QAbstractProxyModel

pyqt,pyside,qsqltablemodel,qsqldatabase
I need to swap the rows and columns of a QSqlRelationalTableModel. After a lot of searching, I wrote a little proxymodel to flip the rows and the columns. It is partly working. The relations in the table are resolved and showed but the dropboxes to choose them gets lost. Also,...

QTreeView not spanning parent width or height

python-3.x,pyside,qtgui
So I am new to QtGui and looking up how to do things, and I found this neat example on QTreeView. When I got it working on my own, I noticed that it didn't fill the space as I'd anticipated: So I have been searching for answers, and not finding...

Maya PySide: Maya crashes when I try to connect custom signal to slot

qt,signals,pyside,maya,slot
I'm about 2 weeks into PySide and I'm loving it, but I'm having trouble understanding some of the more intermediate concepts. Any help would be greatly appreciated. I'm trying to get a few custom QEvents working in PySide with QLineEdit and QCompleter. I'm using the old style for signal/slot connections...

PYSide/PyQt Qtreewidget font color

python,pyqt,pyside
I was wondering how can I change the QtreewidgetItem font color to something else than the predefined Qt colors. I want to use hex color code instead, any ideas? QtGui.QTreeWidgetItem.setForeground(0,QtGui.QBrush(Qt.green)) Cheers!...

How to make a QInputDialog trigger the virtual keyboard to show up?

python,qt,touch,pyside
I am developing a Qt application with Python and PySide. The application runs on Ubuntu Linux; the machine has a touch screen. The virtual keyboard 'onboard' is used to let the user enter text. By default it is hidden. Once a text field in an application like gedit gets the...

Inserting multiple QCheckBox into QTableWidget odd rows

python,pyqt,pyside,qtablewidget,qtablewidgetitem
I'm trying to create a table with 160 Rows, and then inserting a QCheckBox every odd number of rows, specifically on column 10. The problem is, i have to create 80 QCheckBox (one for each row, so they can be separately assigned by the user)... Creating one by one...

QVBoxLayout's 'setAlignment' method not working as expected

python,qt,pyqt,pyside,qvboxlayout
from PySide import QtCore from PySide import QtGui class UI(QtGui.QDialog): def __init__(self): super(UI,self).__init__() self.setWindowTitle('My UI Title') self.create_layout() def create_layout(self): mainLayout = QtGui.QGridLayout() radioButtonSetALayout = QtGui.QVBoxLayout() radioButtonSetBLayout = QtGui.QVBoxLayout() #radio button set A setALabel = QtGui.QLabel('Fruit') radioButtonA = QtGui.QRadioButton('Apple') radioButtonB = QtGui.QRadioButton('Pear') radioButtonSetALayout.addWidget(setALabel)...

How to set up and react to multiple display options?

python,qt,pyqt,pyside,qradiobutton
I'm working on a GUI that will eventually run one of several data analyses depending on which the user selects. In this part of the GUI, I have four radio buttons with options, and then a display button. I would like one of four imported functions to run when the...

How to save a treeview as pdf in PySide/PyQt?

qt,pdf,pyqt,pyside
Short version I have a simple QTreeView embedded in a widget: I want to save the tree as a PDF so users can print it. How can I do this? Details I want to save the tree as a PDF when I click the 'print' button. Based on this question,...

How to modify style hint without QProxyStyle?

python,qt,pyqt,pyside,qstyle
I use Python bindings of Qt (PySide or PyQt4). They don't have QProxyStyle. I want to change the value of a style hint. For example change the SH_Menu_SubMenuPopupDelay popup delay time of a submenu. In native C++ Qt I would use a QProxyStyle and override styleHint and filter for the...

Heights of QPushButton and QLineEdit differ under OS-X

qt,pyqt,pyside
I want to place a QPushButton and a QLineEdit in together one QTreeView cell by putting them in a container widget that has a QHBoxLayout. However, it doesn't look good, the button is taller than the line editor as you can see in my screen shot below. When the cell...

How to undo an edit of a QListWidgetItem in PySide/PyQt?

qt,pyqt,pyside
Short version How do you implement undo functionality for edits made on QListWidgetItems in PySide/PyQt? Hint from a Qt tutorial? The following tutorial written for Qt users (c++) likely has the answer, but I am not a c++ person, so get a bit lost: Using Undo/Redo with Item Views Longer...

QFileSystemWatcher error handling with PySide/PyQt - Python 3.x

python,qt,pyqt,pyside,qfilesystemwatcher
My program utilises Qt's QFileSystemWatcher function to monitor a network directory (not on the local machine itself) for changes, and then run a script when a change is found. This function performs as required for the most part. The program is designed to run 24/7, which has raised some issues...

pyside-rcc “dyld: Library not loaded:…”

osx,pyqt4,pyside,enthought,canopy
I'm a python and Qt rookie and I have some problems running pyside-rcc (and pyrcc4). The problem is not the link to the executable but a library problem it seems. That I'm not a unix wizard, probably doesn't help either:) When I run $ pyside-rcc i get the following error...

(PyQt and PySide) QFileDialog.getExistingDirectory doesn't work on Windows

python,pyqt4,pyside
This code works perfectly fine on mac, after clicking on the button, the dir dialog show up. On Windows, it freezes after the button clicks (refer to the picture). Here is my code: import os import sys from Pyside import QtGui class OpenDir(QtGui.QWidget): def __init__(self): super(OpenDir, self).__init__() self.initUI() def initUI(self):...

Loading animated gif data in QMovie

json,qt,pyside,animated-gif
I'm very new to Qt (specifically PySide) and I'm trying write a script that loads an animated gif from file into a QByteArray and then into a QMovie. The reason for going from file to the QByteArray is because I cannot keep that gif file in memory. I want to...

How to call a function in pyside MainWindow from another python script

python,qt,pyqt,pyside,mainwindow
This is my main.py I have a function called loadShot that I want to call from another class MainWindow(QMainWindow): # Main Window UI def __init__(self, parent=None): QMainWindow.__init__(self, parent) loadUi(os.path.join(SCRIPT_DIRECTORY, 'mainwindow.ui'), self) self.connectInterface() # Connect signals def connectInterface(self): self.scene_Line.textChanged.connect(self.shotName) self.activeProjcet_Line.textChanged.connect(self.shotName) self.character_Line.textChanged.connect(self.shotName)...

How to strikeout text of QStandardItem in Qt/PyQt?

qt,pyqt,pyside,text-styling,qstandarditem
I have a QStandardItemModel in PySide, and want to strikeout text on certain rows (it is a to do list application and when a task is done, I want to strike through the text). Given a QStandardItem that displays fine, based on the documentation I try to strikethrough the text...

QAction triggered signal is not passing checked parameter

python,qt,pyqt,pyside,qt-signals
I have made a menu bar with a QAction which is set to checkable self.display_features_action = QtGui.QAction("Show Features", parent) self.display_features_action.setCheckable(True) self.display_features_action.setChecked(True) Then I connect to this class MyClass: def __init__(....) .... self.display_features_action.triggered.connect(self.my_slot) def my_slot(self, checked) .... But I get a runtime error that the my_slot method takes to arguments, when...

Link QTableWidget cells to webpages

python,qt,hyperlink,pyqt,pyside
I was wondering if it is possible to double click on a cell in a QTableWidget (I've already disabled cell editing) and it opening a link in a web browser. I'm using PyQt4 for Python 3.4.2.

PySide GUI program is unable to call a module which uses open function

python,io,pyqt,pyside
There are three files. The first file is a text file. The second python file reads and prints the text file. The third file is my PySide GUI program, it can not be used within my GUI module. How can I solve this? File1:text.txt hello world File2:pro.py def hello(self): with...

Arabic unicode strings generated by gettext are shown scrambled in Qt UI

python,qt,unicode,pyside,arabic
I am working on a multi-language interface using Qt4 and pyside. Languages works fines on the mainform. I used 2 ways for localization: Qt tr function for Qt UI files Gettext for python scripts and Jinja2 html templates When I show Qt dialogs with gettext translated strings, Arabic strings are...

How to change the accuracy of a floating point number in a cell in QTableWidget?

python,qt,pyqt,pyside,qtablewidget
Here is part of my code: cell = QtWidgets.QTableWidgetItem() cell.setData(QtCore.Qt.EditRole, dics[0][key]) self.data_row_selection_table.setItem(row, nmr_analysis.QT_DATA_COLUMN_ENTRIES.index(key), cell) the application appears like But when I edit the cell, the number's accuracy is limited to centile: How to change the displayed precision of the numbers as well as the limited accuracy during edit?...

PySide: Inconsistent file dialogs

qt,pyside,appearance,qfiledialog
I'm working on an application that requires saving and loading of files. To load files, I'm using QtGui.QFileDialog(), and then calling file_browser.exec_(). That gives this result: To save a file, I'm calling file_browser.getSaveFileName() which gives a completely different looking window: Is there any way to make both of these windows...

arange horizontal line of buttons in Pyside/PyQT/Qt

qt,button,layout,pyqt,pyside
I want to create a simple GUI with PySide/PyQt. In this GUI I want to have a raw with severeal push buttons and the length of the buttons I want to be proportional to its text label. Looking at QPushButton and QHBoxLayout I don't see a posibility this can be...

Produce both versions x32 and x64 under PyInstaller

python,python-2.7,installation,pyside,pyinstaller
I have installed Python 2.7.xx x64 and trying to build executables with PyInstaller. Do I have any chance to build both artifacts x32 and x64 with my existing Python x64? Current PyInstaller script shown below in app.spec file: pyinstaller src/app.spec # -*- mode: python -*- import os import platform from...

Prevent tab cycling with Ctrl+Tab by default with QTabWidget

python,qt,pyqt,pyside,qtabwidget
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...

How to find current QLocale in Qt/PyQt/PySide?

python,qt,pyqt,locale,pyside
How can I find the currently active QLocale? We can find the default system locale with QLocale.system(), but I want something like QLocale.current(), to check if the locale changes I am trying to make are actually working. The documentation has lots of methods for setting locales, or finding the properties...

python problems with super

python-2.7,pyside,maya,super
Ok so I'm having a bit of a problem with the code below. It works as is but if I try to change the part with the comment about me not being able to get super to work correctly to. pipeline_class_call = super(Error_Popup,self) broken_file_w_whats_wrong = pipeline_class_call.whats_wrong_with_file() or to broken_file_w_whats_wrong =...

Highlight item with mouse hover in QTreeView?

qt,pyqt,pyqt4,pyside
I have a QStandardItemModel that I am displaying as a QTreeView with multiple columns (if it matters, I am showing the tree as the central widget of a QMainWindow). I would like to highlight items when the mouse hovers over them. Related pages How to catch mouse over event of...

Python PySide modal Qdialog without OS decoration (title bar, …)

python,qt,qt-creator,pyside,qdialog
I'am going to start coding a GUI with Python and Qt using PySide. I'am using Qt-creator to generate ui for my application. I need a dialog without os decoration such titlebar, statusbar, ... And this Dialog must be modal, or at least it must close when I click outside its...

Qt programs (Canopy GUI, ipython qtconsole) crash in Enthought Canopy Win7 64Bits

python,qt,pyside,enthought,canopy
I installed Canopy 1.5.2 on Windows 7 - 64 Bits. I performed all steps described on Enthought web page, but Canopy GUI won't to start. I realized that the problem is something related with Qt, because applications that don't need such programs (like Mayavi, Pylab, etc) work perfectly. When I...

How to get groups and roles of a QPalette in PyQt/PySide?

pyqt,pyside,qpalette
Instead of "manually" defining lists groups and roles (in my code below), how can I query the PyQt/PySide application for these values? from PyQt4 import QtGui groups = ['Disabled', 'Active', 'Inactive', 'Normal'] roles = [ 'AlternateBase', 'Background', 'Base', 'Button', 'ButtonText', 'BrightText', 'Dark', 'Foreground', 'Highlight', 'HighlightedText', 'Light', 'Link', 'LinkVisited', 'Mid', 'Midlight',...

Make an event where that detects if a boolean becomes true to display a message

python,qt,pyside
I have a GUI application that works with printers connected via USB. What I've got now is the code to detect whenever a printer was connected to the computer. But what I'm trying to achieve is a simple tray message that displays only when someone plugs the printer. So far,...

Overriding text() in PySide QtGui.QStandardItem

python,qt,pyside
I have a class overriding the text() method of QtGui.QStandardItem: class SourceFileItem(QtGui.QStandardItem): def __init__(self, name): super(SourceFileItem, self).__init__("Original Name") def text(self): return "Name from Override" But when I add this to a QStandardItemModel and set that as the model for a listView only the text from the call to the parent...

How can I import pyside modules present in Lib/site-packages folder

python,python-2.7,pyqt,pyside
I am new to python and desktop application. I am developing desktop application using pyside in windows. I followed the steps as per the documentation in pyqt official site. I am using python 2.7.8. I have installed pyside using pip. I have used following command: pip install -U pyside After...

PySide Qt tr() does not translate, context wrong?

python,qt4,translation,pyside
I want to use a QTranslator to be able to use English text labels and still have the software showing German labels. Unfortunately my app does not translate. Loading the .qm file returns True, so it is loaded correctly. The context generated by pyside-lupdate for the class is MainWindow. view...

Differences between python Queue.Queue and multiprocessing.Queue

python,opencv,pyqt,multiprocessing,pyside
My program does not close cleanly when I use the queue from the multiprocessing module (Python 2.7 on Windows) in place of Queue.Queue. Eventually I want to process the frames in imgbuffer using a multiprocessing.Process and then pull back display data using a second queue. This does not work yet...

Why aren't my QRadioButtons 'exclusive' after being added to separate QButtonGroups?

python,qt,pyqt,pyside,qradiobutton
from PySide import QtCore from PySide import QtGui class UI(QtGui.QDialog): def __init__(self): super(UI,self).__init__() self.setWindowTitle('Test UI 2000') self.create_layout() def create_layout(self): mainLayout = QtGui.QVBoxLayout() self.setLayout(mainLayout) fruitLabel = QtGui.QLabel('Fruit') junkLabel = QtGui.QLabel('Junk') buttonGroup1 = QtGui.QButtonGroup() radioButtonA = QtGui.QRadioButton('Apple') radioButtonB = QtGui.QRadioButton('Pear') buttonGroup1.addButton(radioButtonA) buttonGroup1.addButton(radioButtonB) buttonGroup2 =...