Results 1 to 10 of 10

Thread: Qt Property Browser library - notice on edit conclusion

  1. #1
    Join Date
    Nov 2010
    Posts
    97
    Thanks
    6
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt Property Browser library - notice on edit conclusion

    I'm using the QtPropertyBrowser library from the qt-solutions archive. It seems that the only signals I can find to connect to inform me whenever a key is pressed within the LineEditor attached to a string property. I want to find out when the user has CONCLUDED their edits by going to the next item or by hitting the enter key.

    How can this be done?

  2. #2
    Join Date
    Dec 2010
    Location
    BEIJING CHINA
    Posts
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Property Browser library - notice on edit conclusion

    the answer may be noway. I think you can not get this "CONCLUDED" signal. but you can hack the source code.
    look the following code from qttreepropertybrowser.cpp.

    Qt Code:
    1. 181 void QtPropertyEditorView::keyPressEvent(QKeyEvent *event)
    2. 182 {
    3. 183 switch (event->key()) {
    4. 184 case Qt::Key_Return:
    5. 185 case Qt::Key_Enter:
    6. 186 case Qt::Key_Space: // Trigger Edit
    7. 187 if (!m_editorPrivate->editedItem())
    To copy to clipboard, switch view to plain text mode 

    and
    qteditorfactory.cpp:1533: void focusInEvent(QFocusEvent *e);
    qteditorfactory.cpp:1649:void QtCharEdit::focusInEvent(QFocusEvent *e)
    qteditorfactory.cpp:1653: QWidget::focusInEvent(e);
    qtpropertybrowserutils.cpp:399:void QtKeySequenceEdit::focusInEvent(QFocusEvent *e)
    qtpropertybrowserutils.cpp:403: QWidget::focusInEvent(e);
    qtpropertybrowserutils_p.h:147: void focusInEvent(QFocusEvent *e);
    just a tip.

  3. The following user says thank you to xiaokui for this useful post:

    nroberts (17th December 2010)

  4. #3
    Join Date
    Nov 2010
    Posts
    97
    Thanks
    6
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Property Browser library - notice on edit conclusion

    Quote Originally Posted by xiaokui View Post
    the answer may be noway.
    Yeah, I believe you are correct. The lineedit factory connects the the change signal to the textEdited signal in the LineEdit. It's an unfortunate choice. Further, it seems the developers spent a lot of time and effort making it impossible to extend these factories in order to make minor behavioral changes. You not only have to write your own, you have to write all the crap in their template that tracks things.

    I did manage to get MOST of the behavior I want by changing the library to instead connect to the editingFinished signal and then forwarding the string information to the original function that connected to textEdited. Unfortunately I'm not getting the ESC reverts behavior that is common to this kind of control. Looks like in order to get basic, standard behavior I have to write a whole new thing that uses a subclass of LineEdit which generates new signals to revert or something. The function you pointed out might be well worth looking at though and maybe there's an easier answer in editing it.

    Thanks. I was beginning to think this forum didn't have anyone that got it.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt Property Browser library - notice on edit conclusion

    You are doing it all wrong. There is QtAbstractPropertyManager::propertyChanged() signal which should be the only thing interesting for you. Other than that there is QtAbstractPropertyBrowser::currentItemChanged() signal if you want to do it at the widget level.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Nov 2010
    Posts
    97
    Thanks
    6
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Property Browser library - notice on edit conclusion

    Quote Originally Posted by wysota
    You are doing it all wrong.
    This person doesn't know what they are talking about. Neither of the signals they mention do anything even close to what I specifically say I need. The former responds to any change in text DURING edits (exactly what I do NOT want) and the latter is only generated when the user changes the item they're focused on and thus doesn't respond to ENTER nor to ESC.

    Either they don't know anything about the library or they're quite purposefully being a jerk. More likely the latter given the unwarranted arrogance and attitude.
    Last edited by nroberts; 17th December 2010 at 19:09.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt Property Browser library - notice on edit conclusion

    Being rude will not get you even an inch closer to a solution. Reimplement QtAbstractPropertyBrowser::createEditor() of the property browser you are using and then you can connect to any signals in the editor that you want. Just remember that not every property is edited by a QLineEdit.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Nov 2010
    Posts
    97
    Thanks
    6
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Property Browser library - notice on edit conclusion

    Quote Originally Posted by wysota View Post
    Being rude will not get you even an inch closer to a solution. Reimplement QtAbstractPropertyBrowser::createEditor() of the property browser you are using and then you can connect to any signals in the editor that you want. Just remember that not every property is edited by a QLineEdit.
    You're the one being rude. You're also adding absolutely nothing to the conversation. If you'd like to utterly ignore everything I ask I'd be quite happy. You don't seem to even know C++ very well, having once told me to try to #ifdef wrap a class in order to pragmatically create it, and now trying to send me down wild goose chases. I don't particularly appreciate it.


    Added after 6 minutes:


    More info for those that have run into the same problem and may be searching this forum.

    The right answer may have more to do with modifying the library itself. An item delegate is used and that whole system of objects is BUILT to provide the behavior I'm looking for. The propertybrowser library methodically breaks that behavior by inserting overrides to things like setModelData() that break the behavior. After stepping through the handlers it became clear that the ESC vs. RETURN key stuff is already being handled way up the tree in Qt and the difference in how is whether or not this function is called.

    After doing a quick test by modifying that function to result in an emit of a new signal I added to the tree property browser it begins informing me exactly like I want it to. The main issue now is in discovering how this should have been done so that the property goes back to its previous value when the editor is closed and commit was never initiated.

    I'll continue to inform about progress but I'm moving over to the SO question I made for this topic. The signal to noise ratio is much lower over there.

    http://stackoverflow.com/questions/4...hanged-signals
    Last edited by nroberts; 17th December 2010 at 21:53.

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt Property Browser library - notice on edit conclusion

    Quote Originally Posted by nroberts View Post
    You're the one being rude. You're also adding absolutely nothing to the conversation. If you'd like to utterly ignore everything I ask I'd be quite happy. You don't seem to even know C++ very well (...)
    Yes, of course, I'm the one being rude
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #9
    Join Date
    Nov 2010
    Posts
    97
    Thanks
    6
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Property Browser library - notice on edit conclusion

    Decided to go ahead and paste directions for a fix here too:

    So, here's the half-ass fix I came up with:

    I added a "commitItem(QModelIndex)" function to the private thing in the TreePropertyBrowser. Then I call that from the delegate when the setModelData() function is called.

    This then finds the property, calls a new function I added to the AbstractBrowser to fetch the factory for a property and then tells the factory to "commitProperty(QtProperty*)".

    This function is an empty virtual at the base and in the LineEditFactory I override it to apply the property change, which generates the valueChanged() signal.

    With these changes in place the user is able to back out of the edit by hitting the ESC key and I get notified iff they commit the property change by hitting RETURN, focus changing, etc...

    Only works for the tree version at the moment. Probably won't bother trying to make the rest work. In fact I'm probably going to throw this library away and just use the QTreeView myself. IT behaves the way I want, this thing had to be uber-hacked to get the behavior BACK.

    Oh, and the LineEditor's createEditor function has to be edited to remove the connection to textChanged(). To get the correct behavior the property has to remain unchanged until the commitProprty() request is made.
    Last edited by nroberts; 18th December 2010 at 00:49.

  11. #10
    Join Date
    Oct 2012
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Property Browser library - notice on edit conclusion

    Hello Roberts,

    I had passing through all the problems that you described here. Since the beggining when I was looking for a solution the search always bring me here to this topic. It seems that is the only place in the whole internet that have usefull information about QtPropertyBrowser.

    The problem of the behavior of the ESC key was not the hardest problem that I had to solve, since I was working a lot in the events to make the browser works for other tasks, but still is not an easy solution.
    The class QtPropertyEditorDelegate creates the editor and install an event filter, so you can catch the ESC event here:
    Qt Code:
    1. bool QtPropertyEditorDelegate::eventFilter(QObject *object, QEvent *event)
    2. {
    3. if ( e->key() == Qt::Key_Escape ) {
    4. QtProperty* property = m_editorPrivate->currentItem()->property();
    5. property->propertyManager()->abort(property);
    6. }
    7.  
    8. return QItemDelegate::eventFilter(object, event);
    9. }
    To copy to clipboard, switch view to plain text mode 

    In my case I used the property manager to handle with that. But you need to set the old value in the editor and not in the model, since you will let the event propagates and the QItemDelegate will worry about the post events and the behavior of the grid.

    I know that it is too late to help you but maybe it can help someone.

Similar Threads

  1. Help with property browser
    By Jsvc in forum Qt Programming
    Replies: 2
    Last Post: 3rd October 2010, 01:49
  2. Compilation of QT Property Browser
    By yccheok in forum Qt Programming
    Replies: 7
    Last Post: 28th July 2010, 23:39
  3. How to hide subproperties in Qt Property Browser?
    By yyalli in forum Qt Programming
    Replies: 0
    Last Post: 15th April 2010, 17:29
  4. Qt Creator Adding a Help File (for the Property Browser)
    By BobTheProg in forum Qt Tools
    Replies: 5
    Last Post: 29th January 2010, 23:44
  5. Qt Property Browser Framework - Redo/Undo
    By monadic_kid in forum Qt Programming
    Replies: 2
    Last Post: 3rd December 2009, 10:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.