qtgui

Overriding QPaintEvents in PyQt

别等时光非礼了梦想. 提交于 2019-12-01 03:54:07
问题 I'm trying to create a TextEdit widget that will have a delimiter line. As a start, I've created a MyTextEdit class (as a subclass of a QTextEdit ) and overridden its paintEvent() method: import sys from PyQt4.QtGui import QApplication, QTextEdit, QPainter class MyTextEdit(QTextEdit): """A TextEdit widget derived from QTextEdit and implementing its own paintEvent""" def paintEvent(self, event): painter = QPainter(self) painter.drawLine(0, 10, 10, 10) QTextEdit.paintEvent(self, event) app =

How to check the selected version of Qt in a .pro file?

为君一笑 提交于 2019-11-30 12:36:56
问题 I have multiple versions of Qt installed, and I need to compile my project with all of them. Using a pro file, I could not find in the documentation how to do a conditional compilation. Ideally, this is what I would like to do: QT_VERSION = 5 # this can be 4, set manually if(QT_VERSION == 5) { QT += widgets } if(QT_VERSION == 4) { QT += gui } Naturally, the if() command does not exist in pro files. Is there a better way to do the same thing? 回答1: You can use conditional functions and scopes

How to set Input Mask and QValidator to a QLineEdit at a time in Qt?

狂风中的少年 提交于 2019-11-30 09:25:44
I want a line edit which accepts an ip address. If I give input mask as: ui->lineEdit->setInputMask("000.000.000.000"); It is accepting values greater than 255. If I give a validator then we have to give a dot(.) after every three digits. What would the best way to handle it? lpapp It is accepting value greater than 255. Absolutely, because '0' means this : ASCII digit permitted but not required. As you can see, this is not your cup of tea. There are at least the following ways to circumvent it: Write a custom validator Use regex Split the input into four entries and validate each entry on its

Qt debian/ubuntu: Can't compile, error: cannot find -lGL

大兔子大兔子 提交于 2019-11-30 09:20:12
问题 I have a problem building applications in Qt on Debian. When I try to compile anything I get: /usr/bin/ld: cannot find -lGL collect2: error: ld returned 1 exit status make: *** [test] Error 1 14:38:52: Proces "/usr/bin/make" zakończył się kodem wyjściowym 2. Last line means: Procces(...) exited with code: 2 Any idea what's wrong? 回答1: Since this is a linker error, you may have one of two problems: You don't have libGL installed libGL is installed but not in your system path. If libGL isn't

How to check the selected version of Qt in a .pro file?

主宰稳场 提交于 2019-11-30 04:48:13
I have multiple versions of Qt installed, and I need to compile my project with all of them. Using a pro file, I could not find in the documentation how to do a conditional compilation. Ideally, this is what I would like to do: QT_VERSION = 5 # this can be 4, set manually if(QT_VERSION == 5) { QT += widgets } if(QT_VERSION == 4) { QT += gui } Naturally, the if() command does not exist in pro files. Is there a better way to do the same thing? Nemanja Boric You can use conditional functions and scopes here: QT_VERSION = 5 # this can be 4, set manually equals(QT_VERSION, 5){ QT += widgets }

How do I add a header with data to a QTableWidget in Qt?

亡梦爱人 提交于 2019-11-29 08:02:48
I'm still learning Qt and I am indebted to the SO community for providing me with great, very timely answers to my Qt questions. Thank you. I'm quite confused on the idea of adding a header to a QTableWidget . What I'd like to do is have a table that contains information about team members. Each row for a member should contain his first and last name, each in its own cell, an email address in one cell, and office in the other cell. I'd to have a header above these columns to name them as appropriate. I'm trying to start off easy and get just the header to display "Last" (as in last name). Here

implementing pyqtgraph for live data graphing

為{幸葍}努か 提交于 2019-11-28 19:58:45
I am trying to get a live plot of data as it is being collected by an instrument using pyqtgraph. The data collection is handled by the main process this is then passed over a connection to a subprocess that plots it. I am just trying to pass the new data and have it update when the new data is passed. I have tried to implement this by putting the connection read inside the Qt Timer update loop but then I have difficulty passing the graph data (which I want to append to) between successive update cycles. I omitted from the code below, but basically I want to join up successive lots of connData

How do I add a header with data to a QTableWidget in Qt?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 01:57:25
问题 I'm still learning Qt and I am indebted to the SO community for providing me with great, very timely answers to my Qt questions. Thank you. I'm quite confused on the idea of adding a header to a QTableWidget . What I'd like to do is have a table that contains information about team members. Each row for a member should contain his first and last name, each in its own cell, an email address in one cell, and office in the other cell. I'd to have a header above these columns to name them as

PyQt: How to hide QMainWindow

给你一囗甜甜゛ 提交于 2019-11-27 22:35:59
Clicking Dialog_01's button hides its window and opens Dialog_02. Clicking Dialog_02's button should close its windows and unhide Dialog_01. How to achieve it? import sys, os from PyQt4 import QtCore, QtGui class Dialog_02(QtGui.QMainWindow): def __init__(self): super(Dialog_02, self).__init__() myQWidget = QtGui.QWidget() myBoxLayout = QtGui.QVBoxLayout() Button_02 = QtGui.QPushButton("Close THIS and Unhide Dialog 01") Button_02.clicked.connect(self.closeAndReturn) myBoxLayout.addWidget(Button_02) myQWidget.setLayout(myBoxLayout) self.setCentralWidget(myQWidget) self.setWindowTitle('Dialog 02

PyQt5 and QtGui module not found

谁说胖子不能爱 提交于 2019-11-27 14:27:32
Is there some reason that QtGui is packaged with PyQt5??? I am using Mark Summerfield's Rapid GUI programming book. Obviously this book was written with Qt4 in mind, but I have been recommended to use Qt5, and PyQt5. I want to run the first example code in chapter 4. The code begins with the following import statements: import sys import time from PyQt5.QtCore import * from PyQt5.QtGui import * To which the compiler responds: Traceback (most recent call last): File "wakeUp.py", line 4, in <module> from PyQt5.QtGui import * ImportError: No module named 'PyQt5.QtGui' Note that the PyQt5.QtCore