qlineedit

Connecting multiple signals to a single slot in Qt

♀尐吖头ヾ 提交于 2019-12-06 10:11:53
问题 I'm trying to keep track of the textChanged() signal on for handful of QTextEdits. I want to do the same thing regardless of the text edit emitting the signal: uncheck its associated checkbox in a QListWidget if it becomes empty and leave it checked otherwise. The function I have so for is as follows: void MainWindow::changed() { QString tempStr = ui->hNMRedit->toPlainText(); if(tempStr != "") { ui->checkList->item(0)->setCheckState(Qt::Checked); } else { ui->checkList->item(0)->setCheckState

How to use QlineEdit to enter integer values

二次信任 提交于 2019-12-05 09:14:15
问题 I am trying to use QlineEdit . How would I enter a value into the edit bar when I run the program and get that valued stored as a variable to be used later. So far I have only found out how to enter text using void parameter_settings::on_lineEdit_textEdited(const QString &arg1) { ui->lineEdit->setText(""); } I have a GUI that requires the user to enter a value within a specific range. That value would be stored as a variable for later use. I have read about validators but can't get it to work

Hide QLineEdit blinking cursor

梦想的初衷 提交于 2019-12-05 06:37:42
I am working on QT v5.2 I need to hide the blinking cursor (caret) of QLineEdit permanently. But at the same time, I want the QLineEdit to be editable (so readOnly and/or setting editable false is not an option for me). I am already changing the Background color of the QLineEdit when it is in focus, so I will know which QLineEdit widget is getting edited. For my requirement, cursor (the blinking text cursor) display should not be there. I have tried styleSheets , but I can't get the cursor hidden ( {color:transparent; text-shadow:0px 0px 0px black;} ) Can someone please let me know how can I

QValidator for hex input

只愿长相守 提交于 2019-12-05 06:30:37
I have a Qt widget which should only accept a hex string as input. It is very simple to restrict the input characters to [0-9A-Fa-f] , but I would like to have it display with a delimiter between "bytes" so for example if the delimiter is a space, and the user types 0011223344 I would like the line edit to display 00 11 22 33 44 Now if the user presses the backspace key 3 times, then I want it to display 00 11 22 3 . I almost have what i want, so far there is only one subtle bug involving using the delete key to remove a delimiter. Does anyone have a better way to implement this validator?

qlineedit auto resize to content

十年热恋 提交于 2019-12-05 06:01:17
I'm trying to do a small widget with a lineedit and a pushbutton. If the button is clicked, it should open a filedialog where I can select a file. The file name should then showed in the lineedit. Here is what i got so far: #include "widget_openimage.h" #include <QFontMetrics> Widget_openimage::Widget_openimage(QWidget *parent) : QWidget(parent) { // horizontal layout layout = new QHBoxLayout(); // linedit on the left which shows the path of the chosen file lineedit = new QLineEdit(); lineedit->setReadOnly(true); // pushbutton on the right to select the file btn = new QPushButton("..."); btn-

How to display Arabic notations in left-to-right direction in QLineEdit/QLabel etc.?

痴心易碎 提交于 2019-12-05 04:32:22
问题 In Qt's implementation arabic notation is shown in right-to-left direction, thus any strings that contain arabic notations will be right-aligned. But what my application wants to do is showing all texts in left-to-right direction, whether it contains arabic notations or not. And all texts are left-aligned. An example is shown below: This is what I want to implement This is how QLineEdit displays texts containing arabic notations in its default way This is how QLabel does it EDIT: Paste the

Fail to clear QLineEdit after selecting item from QCompleter

瘦欲@ 提交于 2019-12-04 20:11:35
using PopupCompletion mode when you select an item (using arrow keys) and press return - lineEdit should become empty (i clear lineEdit when return is pressed), but lineEdit does not become empty. (If you press 'Enter' again it will empty the lineEdit). So i think pressing return does clear lineEdit, but pressing return also tells QCompleter to insert selected item into lineEdit, so it seems like nothing happens. But, if you click the item insted of selecting it with arrows - everything works fine. I tried to find the solution on the internet, but i found only one person that had the same

Connecting multiple signals to a single slot in Qt

♀尐吖头ヾ 提交于 2019-12-04 15:38:11
I'm trying to keep track of the textChanged() signal on for handful of QTextEdits. I want to do the same thing regardless of the text edit emitting the signal: uncheck its associated checkbox in a QListWidget if it becomes empty and leave it checked otherwise. The function I have so for is as follows: void MainWindow::changed() { QString tempStr = ui->hNMRedit->toPlainText(); if(tempStr != "") { ui->checkList->item(0)->setCheckState(Qt::Checked); } else { ui->checkList->item(0)->setCheckState(Qt::Unchecked); } } With the current approach, I would have to make a function like this for every

pyqt5 autocomplete QLineEdit - Google places autocomplete

不想你离开。 提交于 2019-12-04 02:06:23
问题 I am trying to create something like this (autocomplete places) in pyqt5 QLineEdit. There is a class called QCompleter with which i can suggest the content, but it requires an already formed list, but this google places api is a suggestion based function, how can i send each keystroke to google api and get the suggestion back and load in Qtextedit, is there a better way to do it 回答1: For this case you can create a custom model that makes a request using Place Autocomplete, and set that model

How to use QlineEdit to enter integer values

帅比萌擦擦* 提交于 2019-12-03 21:48:35
I am trying to use QlineEdit . How would I enter a value into the edit bar when I run the program and get that valued stored as a variable to be used later. So far I have only found out how to enter text using void parameter_settings::on_lineEdit_textEdited(const QString &arg1) { ui->lineEdit->setText(""); } I have a GUI that requires the user to enter a value within a specific range. That value would be stored as a variable for later use. I have read about validators but can't get it to work as intended. I am not entirely sure what your question is, but you can get the input from a QLineEdit