Il giorno lun 18 feb 2019 alle ore 05:31 John F Sturtz <john at sturtz.org> ha
scritto:
> Wow! Thank you so much for all this information. In spite of the time I
> have spent with PyQt, it is clear I still have much to learn. :-/
>
You'll never end to learn ;-)
I still learn things from day to day (also by replying to this mailing
list, as in this case).
While I'm still "stuck" with Python 2.7 and PyQt4 (which are *very* old)
for my most important project, I realize that there are dozens of things I
still do not know yet, even with products that old. And that's good :-)
> A much more "elegant" way to do so would be to request the actual view
> from the parent argument of createEditor(); keep in mind, though, that the
> parent of the editor is the viewport of the view (since an item view is a
> QAbstractScrollArea and its contents are in an embedded "scrollable"
> QWidget), so the reference to the view is the parent() of the parent
> argument of createEditor() method, actually.
>> This is great! I was looking for a way to get a reference to the view
> from the delegate, but I hadn't been able to find one. Didn't look quite
> hard enough ...
>
That's neat, isn't it? It took me a while to understand that, since the
parent didn't seem to be a "real" and "usable" widget until I actually
realized the QAbstractScrollArea inheritance of item views, and I'm still
not quite sure that it's the best (and "programmatically correct") way to
handle this, but I think that it's a better and more coherent way to
achieve that in most cases.
Obviously, if you really know what you're doing (and, most importantly,
what you might be doing in the future), setting a "virtual" parent view
while init-ing the delegate is fine enough.
PS: in your code, you've been using model.setData() inside the
> setEditorData() method of the itemDelegate, which not only doesn't makes
> not much sense, but might also result in an infinite recursion.
>> This is a fallout of the following peculiar fact: My actual intention is
> to use a QLabel as the delegate editor widget, and not a QLineEdit. I
> know that seems weird, but it gives me more precise control over the
> editing that occurs. (Basically, I respond to keyboard input, modify the
> QLabel's text, then redisplay it. In the attached example, I changed the
> QLineEdit back to a QLabel, so you can see what I mean).
>[...]
>There is one thing in the current version that still puzzles me: In the
> most recent round of messing around, I decided to subclass QLabel, and
> then use an object of the subclass as the editor widget rather than an
> actual QLabel. And I decided to move keypress handling from eventFilter()
> in the delegate to keyPressEvent() in the editor widget subclass. In the
> process, it seemed to change the way Tab is handled.
>[...]
>The latter is the default behavior for the Tab character, I believe. But
> the former is actually what I want. So it works the way I'd wish when I
> handle keyboard input in the delegate. But I'm not doing anything with Tab
> character in either case, so it seems strange to me that in one case I'm
> getting one behavior, and in the other case another.
>
I'm not quite sure I'm following you on that.
I think I can understand your "precise control" needs, but if you can
better explain what your needs are, we might help with that.
Using a QLabel for editing is not suggested, not only because it's not its
purpose, but also because it doesn't provide sufficient editing
cababilities and aidings, from both programming and UX perspectives (and
I'm usually mostly focused on the latter).
Let me explain on that.
A label doesn't show the editing cursor (you might object that for simple
editings it doesn't matter that much, but *knowing* where you're typing is
a huge feedback) and it doesn't provide any selection nor clipboard
implementation. From the user point of view that's not good, as its usage
is not intuitive: while the user can "learn" how it works from its
behavior, it's usage doesn't justify the change of behavior between similar
and common [table/editing] user interfaces.
>From a GUI programming perspective, it's also a problem whenever "common"
keyboard shortcuts come in place. If I type a valid value in the editing
cell and then use any keyboard navigation shortcut (arrows, page up/down,
home/end, and further modifier combinations) I'd expect to "move" the
editing cursor, while in you implementation it results in submitting the
value and changing focus to another cell in the view (since the value is
considered valid), according to the QKeySequence class implementation of
QKeyEvents of an item view. So, you'll need to catch *all* those cases in
the eventFilter() according to those listed in
https://doc.qt.io/archives/qt-4.8/qabstractitemview.html#details ,
including possible multiple cell selection scenarios, since you're
returning False to all "unrecognized" cases of keyboard events - thus
letting the parent object (the item view, its container layout/widget,
etc) handle those events.
That said, it might be better to keep the default QLineEdit editor. You can
then set your custom QValidator to the editor in the createEditor() or even
implement your own editor. Since it seems you're requiring numeric values
(as it looks from the regex you use in the validate() method) you can even
return a custom inherited QSpinBox, and implement its own validate(),
fixup() and/or textFromValue() methods according to your needs. I know it
might look a bit more complicated to program with, but you'll eventually
realize that it's a better solution once you understand how they behave and
how all this can actually help both you and your users.
Finally, if you are really aware about those issues, and you really want to
"escape" tab keypresses only, just add an elif key ==
QtCore.Qt.Key_Tab statement
to your eventFiler() and check for the QtCore.Qt.ShiftModifier.
In any event, I think I'm making progress. Thanks again for the help! I
> really appreciate it.
>
Glad to be of any help :-)
Cheers,
Maurizio
--
脠 difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/pyqt/attachments/20190221/b2db94bd/attachment.html>
More information about the PyQt
mailing list
‘She has never mentioned her father to me. Was he—well, the sort of man whom the County Club would not have blackballed?’ "We walked by the side of our teams or behind the wagons, we slept on the ground at night, we did our own cooking, we washed our knives by sticking them into the ground rapidly a few times, and we washed our plates with sand and wisps of grass. When we stopped, we arranged our wagons in a circle, and thus formed a 'corral,' or yard, where we drove our oxen to yoke them up. And the corral was often very useful as a fort, or camp, for defending ourselves against the Indians. Do you see that little hollow down there?" he asked, pointing to a depression in the ground a short distance to the right of the train. "Well, in that hollow our wagon-train was kept three days and nights by the Indians. Three days and nights they stayed around, and made several attacks. Two of our men were killed and three were wounded by their arrows, and others had narrow escapes. One arrow hit me on the throat, but I was saved by the knot of my neckerchief, and the point only tore the skin a little. Since that time I have always had a fondness for large neckties. I don't know how many of the Indians we killed, as they carried off their dead and wounded, to save them from being scalped. Next to getting the scalps of their enemies, the most important thing with the Indians is to save their own. We had several fights during our journey, but that one was the worst. Once a little party of us were surrounded in a small 'wallow,' and had a tough time to defend ourselves successfully. Luckily for us, the Indians had no fire-arms then, and their bows and arrows were no match for our rifles. Nowadays they are well armed, but there are[Pg 41] not so many of them, and they are not inclined to trouble the railway trains. They used to do a great deal of mischief in the old times, and many a poor fellow has been killed by them." As dusk came on nearly the whole population of Maastricht, with all their temporary guests, formed an endless procession and went to invoke God's mercy by the Virgin Mary's intercession. They went to Our Lady's Church, in which stands the miraculous statue of Sancta Maria Stella Maris. The procession filled all the principal streets and squares of the town. I took my stand at the corner of the Vrijthof, where all marched past me, men, women, and children, all praying aloud, with loud voices beseeching: "Our Lady, Star of the Sea, pray for us ... pray for us ... pray for us ...!" It had not occurred to her for some hours after Mrs. Campbell had told her of Landor's death that she was free now to give herself to Cairness. She had gasped, indeed, when she did remember it, and had put the thought away, angrily and self-reproachfully. But it returned now, and she felt that she might cling to it. She had been grateful, and she had been faithful, too.[Pg 286] She remembered only that Landor had been kind to her, and forgot that for the last two years she had borne with much harsh coldness, and with a sort of contempt which she felt in her unanalyzing mind to have been entirely unmerited. Gradually she raised herself until she sat quite erect by the side of the mound, the old exultation of her half-wild girlhood shining in her face as she planned the future, which only a few minutes before had seemed so hopeless. After he had gloated over Sergeant Ramsey, Shorty got his men into the road ready to start. Si placed himself in front of the squad and deliberately loaded his musket in their sight. Shorty took his place in the rear, and gave out: The groups about each gun thinned out, as the shrieking fragments of shell mowed down man after man, but the rapidity of the fire did not slacken in the least. One of the Lieutenants turned and motioned with his saber to the riders seated on their horses in the line of limbers under the cover of the slope. One rider sprang from each team and ran up to take the place of men who had fallen. "As long as there's men and women in the world, the men 'ull be top and the women bottom." Then, in the house, the little girls were useful. Mrs. Backfield was not so energetic as she used to be. She had never been a robust woman, and though her husband's care had kept her well and strong, her frame was not equal to Reuben's demands; after fourteen years' hard labour, she suffered from rheumatism, which though seldom acute, was inclined to make her stiff and slow. It was here that Caro and Tilly came in, and Reuben began to appreciate his girls. After all, girls were needed in a house—and as for young men and marriage, their father could easily see that such follies did not spoil their usefulness or take them from him. Caro and Tilly helped their grandmother in all sorts of ways—they dusted, they watched pots, they shelled peas and peeled potatoes, they darned house-linen, they could even make a bed between them. HoME一级毛片视频免费公开
ENTER NUMBET 0018www.ysxxy.com.cn lounen.com.cn www.dxdj093.com.cn www.miasole.com.cn www.90le.com.cn tbjb.com.cn www.dfwf832.com.cn www.powur.com.cn www.bksd.com.cn www.liuhuang.net.cn