Mailing List Archive

Open a new window by mouse clicking in the QLineEdit field and not by clicking of a button
Hi all,
I'm looking for an approach, but couldn't find any appropriate answer to my problem:
On my GUI on a tablet, I have bunch of QlineEdit widgets for the settings of my task.
Because we have no keyboard connected to the tablet, I have put two buttons ("+" and "-") around each QLineEdit widget to increase or decrease its value.
When the target value is far away from the displayed one in the QLineEdit, I have to click lots of times to reach the end value.
Due to this ugliness feature, I wanted to offer to the user the possibility to click in the edit field to get another window with a numeric keypad to type the target value. And then by clicking an OK button, the new window will be closed and the typed value will be taken into the QLineEdit widget of my original GUI.
In all my searches, I found examples to open new windows by clicking a button and not by clicking in an edit field.
I used the following line to have an edit field on window1.

self.text_from_window2 = QLineEdit('Setting Value')

And wanted to open another window (window2) in which I programmed a numeric keypad. By typing the desired value on this keypad and enter OK, this value should be taken to the edit field of window1.
But the following line brings an error that QLineEdit has no attribute "clicked".

self.text_from_window2.clicked().connect(self.show_keypad_window)

I tried to use other attributes like focus, textChanged or textEdited. None of them could help me.
Is it at all possible to use QLineEdit with mouse click to generate an action (open new window)?
Has anyone an example of such a code snippet?
I am very curious to see if someone has a solution to my problem.

Regards
Mohsen
--
https://mail.python.org/mailman/listinfo/python-list
Re: Open a new window by mouse clicking in the QLineEdit field and not by clicking of a button [ In reply to ]
> On 5 Oct 2021, at 22:07, Mohsen Owzar <mohsen.owzar@gmail.com> wrote:
>
> ?Hi all,
> I'm looking for an approach, but couldn't find any appropriate answer to my problem:
> On my GUI on a tablet, I have bunch of QlineEdit widgets for the settings of my task.
> Because we have no keyboard connected to the tablet, I have put two buttons ("+" and "-") around each QLineEdit widget to increase or decrease its value.
> When the target value is far away from the displayed one in the QLineEdit, I have to click lots of times to reach the end value.
> Due to this ugliness feature, I wanted to offer to the user the possibility to click in the edit field to get another window with a numeric keypad to type the target value. And then by clicking an OK button, the new window will be closed and the typed value will be taken into the QLineEdit widget of my original GUI.
> In all my searches, I found examples to open new windows by clicking a button and not by clicking in an edit field.

What I have done is use mouse move events to change values.
I touch the field then drag my finger to change the value.
I only use linear scaling but you could have code that can tell slow drag
from fast drag and scale the value.

> I used the following line to have an edit field on window1.
>
> self.text_from_window2 = QLineEdit('Setting Value')
>
> And wanted to open another window (window2) in which I programmed a numeric keypad. By typing the desired value on this keypad and enter OK, this value should be taken to the edit field of window1.
> But the following line brings an error that QLineEdit has no attribute "clicked".
>
> self.text_from_window2.clicked().connect(self.show_keypad_window)
>
> I tried to use other attributes like focus, textChanged or textEdited. None of them could help me.
> Is it at all possible to use QLineEdit with mouse click to generate an action (open new window)?
> Has anyone an example of such a code snippet?
> I am very curious to see if someone has a solution to my problem.

By the way there is a great PyQt mailing list that you might like to join.

https://www.riverbankcomputing.com/mailman/listinfo/pyqt

Lots of knowledgeable PyQt developers hang out on that list.

Barry

>
> Regards
> Mohsen
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list