qlineedit darf nach falscher Eingabe nicht verlassen werden

Python und das Qt-Toolkit, erstellen von GUIs mittels des Qt-Designers.
Antworten
inuse2
User
Beiträge: 3
Registriert: Sonntag 20. Januar 2013, 20:51

Hallo zusammen,

ich hätte gerne, dass nach Eingabe eines fehlerhaften Wertes qlineedit nicht verlassen werden darf, solange der eingegebene Wert fehlerhaft ist.
Es soll also nicht möglich sein, mit der Maus ein anderes widget anzuklicken, so dass dessen event ausgelöst wird. Ebenso sollen auch KeyEvents (Tab-Taste) abgefangen werden.
Ist so etwas mit PyQt machbar? Kann mir jemand helfen?

Vielen Dank im voraus!
Benutzeravatar
pillmuncher
User
Beiträge: 1484
Registriert: Samstag 21. März 2009, 22:59
Wohnort: Pfaffenwinkel

One morning, as Master Foo was walking trough the garden, a student approached
him. After he bowed respectfully to the Master, the student said: "Master, I
am very troubled." The master replied: "What troubles you, grasshopper?"

The student said: "Well, Master, the other students set me in charge of the student's
refectory. My duty is to keep it clean and furbish it every day. This is a great honor,
as you can see." The Master nodded in agreement. "But", the student continued,
"now I am worried that I cannot keep up with my chores."

"Why are you worried?" the Master investigated. "Master, the other students
make my life miserable. They never wipe their feet before they enter the refectory
and they always throw food on the floor, so I keep having to clean up after them,
which takes more and more time every day. I asked them repeatedly to stop doing
these things and not make my life miserable, and they always promise to do so,
but they won't keep their promises."

The Master said to the student: "Grasshopper, I will eat with you students today
in your refectory. Make shure everyone is there."

The student bowed with gratitude and took his leave from Master Foo.

At noon, when Master Foo arrived, his shoes were dirty with mud but he did not
wipe them before entering the refectory, leaving behind him a trail of very muddy
footprints. The student was vexed. Then, when the student served Master Foo a
bowl of rice, the Master took the bowl and threw it across the refectory so the
whole floor was sprinkled with grains of rice.

In that moment the student was enlightened.
In specifications, Murphy's Law supersedes Ohm's.
inuse2
User
Beiträge: 3
Registriert: Sonntag 20. Januar 2013, 20:51

Aha, sollte ich vielleicht doch bei Java bleiben? Dort gibt es die JGlassPane, mit der geht das. Oder habe ich den versteckten Hinweis nicht erkannt?
lunar

@inuse2 Weise dem QLineEdit einen entsprechenden QValidator zu.

@pillmuncher Das war nicht Dein bester Beitrag… sage dem OP doch zumindest, was er in Deinen Augen falsch gemacht hat. Wenn Du einfach nur coole Zitate loswerden willst, gibt es bessere Gelegenheit.
inuse2
User
Beiträge: 3
Registriert: Sonntag 20. Januar 2013, 20:51

@lunar: vielen Dank für den Hinweis, somit hat pillmuncher indirekt zu einer Lösung beigetragen.
Antworten