qtgui

QTableView and double click on a cell

梦想的初衷 提交于 2020-12-06 03:34:27
问题 I am working on a test case editor. This editor contains USART a transmit and receive packet format. The editor is a table view. The transmit and receive packet is eight bytes long, for example: 0x01 0x02 0x03 ... 0x08 It is in my fifth and sixth column. Now, I want the cells in this column to be read only, but when I double-click on any cell in these columns a pop-up widget is displayed. This widget will contain eight boxes in the text edit, where the user can enter the packet format (i.e.

PyQt: LineEdit widget's placement inside of FormLayout

心已入冬 提交于 2020-01-30 08:53:06
问题 A QtGui.QLineEdit line_edit widget is placed inside of QtGui.QFormLayout Form layout using .addRow() method. my_formLayout.addRow(my_label, my_lineEdit) To make a line_edit widget to stick to a dialog window's edges (so it re-sizes with the dialog) tried using sizePolicy: sizePolicy = my_lineEdit.sizePolicy() sizePolicy.setHorizontalStretch(1) my_lineEdit.setSizePolicy( sizePolicy ) There are no errors. But the line_edit widget still doesn't stick to the edges of the dialog... What could be

Why is my mousePressEvent called twice?

[亡魂溺海] 提交于 2020-01-07 01:21:16
问题 I want to make a QLabel clickable and followed this "how-to". I was not sure how to get this piece of code into my GUI (I am quite newbie to qt). What I did was: I created a new class (just copy/paste of ClickableLabel from the link, but I changed the signal to clicked(QMouseEvent* event) ) I added a QLabel to my GUI and "promoted" it to a ClickableLable I connected the signal to a slot of my main window where I std::cout some stuff: connect(this->ui->label,SIGNAL(clicked(QMouseEvent*)), this

QOpenGLFunctions missing important OpenGL functions

梦想与她 提交于 2020-01-03 13:05:11
问题 QOpenGLFunctions seems to be missing important functions such as glInvalidateFramebuffer and glMapBuffer. From what I understand QOpenGLFunctions loads the intersection of both desktop OpenGL functions and ES functions. If that's the case, why aren't these two functions present? From what I can tell glMapBuffer is in both. Am I misunderstanding QOpenGLFunctions, or are they actually missing functions(unlikely)? 回答1: There are multiple reasons for those two cases and the one in the comment: 1)

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

匆匆过客 提交于 2019-12-30 03:19:07
问题 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? 回答1: 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

QT Signal / Slot

懵懂的女人 提交于 2019-12-25 01:39:03
问题 I've got a question about signals and slots. In my app, I want to connect a signal from one object to a textEdit in a dialog window. My signal emits a QString ; if I violate encapsulation (by making the UI public instead of private) and connect the signal directly to the textEdit it works. But I feel that it's not the right way. If I make something like the following: connect(m_osgWidget->picker.get(), SIGNAL(setX(QString)), m_addAgentDlg, SLOT(getX(QString))); where: void getX(QString) {

Terminate PyQt Application [duplicate]

♀尐吖头ヾ 提交于 2019-12-24 20:24:51
问题 This question already has answers here : Proper way to quit/exit a PyQt program (2 answers) Closed 12 months ago . If the user interacts with the application, for example pressing a button, and the user clicks then on the X button, the application keeps running, but the window closes. How can I fully terminate the application. It’s built using PyQt5. 回答1: Here is a simple "Hello World" example, I copied from the Qt tutorials. It uses sys.exit(...) to exit the application. import sys from

QTreeView always displaying the same data

送分小仙女□ 提交于 2019-12-24 07:38:30
问题 I have a tree of items. It is like this: Categorias (root) - General --- Computadoras --- Tablets - Insumos --- Cartuchos The problem is that the QTreeView is being completed always with the same information. I get a tree view looking like this: Categorias (root) - General --- General --- Insumos - Insumos --- General I have put a "print" in the index() method in order to see if the index was being created, and then, when I enter, for example, the "General" category for the first time,

Selecting a piece of text using QTextCursor

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 03:01:35
问题 Having problems with selecting pieces of text using the Qt framework. For example if i have this document : "No time for rest". And i want to select "ime for r" and delete this piece of text from the document, how should i do it using QTextCursor? Here is my code: QTextCursor *cursor = new QTextCursor(ui->plainTextEdit->document()); cursor->setPosition(StartPos,QTextCursor::MoveAnchor); cursor->setPosition(EndPos,QTextCursor::KeepAnchor); cursor->select(QTextCursor::LineUnderCursor); cursor-