Page 2 of 2 FirstFirst 12
Results 21 to 27 of 27

Thread: How do I obtain mouse hover/popup functionality in a Qtableview?

  1. #21
    Join Date
    Oct 2008
    Location
    Europe
    Posts
    37
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Wink Re: How do I obtain mouse hover/popup functionality in a Qtableview?

    in my_model::data I added a:
    Qt Code:
    1. if(role== Qt::EditRole ) {
    2. return QString(index.data(0).toString());
    3. }
    To copy to clipboard, switch view to plain text mode 
    since I read on http://wiki.qtcentre.org/index.php?t...tractItemModel
    that Qt::EditRole returns a string, and now upon doubleclick the values "stay" in the cell.
    But the story isnt over, I still dont understand how to use QSqlTableModel 's delegates on my_model too
    (i have a datetime type in mysql which automagically has a spinbox editor in QSqlTableModel )

    Someone should further edit the wiki article with examples of the functions
    Attached Images Attached Images
    Last edited by wysota; 6th May 2009 at 08:35. Reason: missing [code] tags

  2. #22
    Join Date
    Oct 2008
    Location
    Europe
    Posts
    37
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Re: How do I obtain mouse hover/popup functionality in a Qtableview?

    bump.
    I still havent solved the last issue...

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

    Default Re: How do I obtain mouse hover/popup functionality in a Qtableview?

    Quote Originally Posted by georgep View Post
    since I read on http://wiki.qtcentre.org/index.php?t...tractItemModel
    that Qt::EditRole returns a string,
    It returns a variant. The default delegate interprets it as a string later on. So you can return an int from this role and it will be displayed as a textual representation of the integer.

    But the story isnt over, I still dont understand how to use QSqlTableModel 's delegates on my_model too
    (i have a datetime type in mysql which automagically has a spinbox editor in QSqlTableModel )
    I don't understand the problem. What is it exactly that you don't know?

    Someone should further edit the wiki article with examples of the functions
    Hmm... why don't you do it?
    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.


  4. #24
    Join Date
    Oct 2008
    Location
    Europe
    Posts
    37
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How do I obtain mouse hover/popup functionality in a Qtableview?

    Quote Originally Posted by wysota View Post
    It returns a variant. The default delegate interprets it as a string later on. So you can return an int from this role and it will be displayed as a textual representation of the integer.



    I don't understand the problem. What is it exactly that you don't know?

    it might be simple, but I dont understand how to get the spinbox delegate in the datetime column of the database (and not in others)[see pic]. I searched for the code in
    src\sql\models\qsqltablemodel.cpp but couldnt manage to find anything...


    Quote Originally Posted by wysota View Post
    Hmm... why don't you do it?
    Because im very new to Qt, and not very experienced in cpp either so there is a significant chance i would write something stupid.

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

    Default Re: How do I obtain mouse hover/popup functionality in a Qtableview?

    Quote Originally Posted by georgep View Post
    it might be simple, but I dont understand how to get the spinbox delegate in the datetime column of the database (and not in others)[see pic]. I searched for the code in
    src\sql\models\qsqltablemodel.cpp but couldnt manage to find anything...
    Because it's nothing related to the model. You need to provide your own delegate - subclass one of the existing classes and reimplement QAbstractItemDelegate::createEditor() to return a spinbox for the appropriate column or datatype.


    Because im very new to Qt, and not very experienced in cpp either so there is a significant chance i would write something stupid.
    So please restrain yourself from such statements. It's either writing examples at the wiki or answering questions here. The time and will of people willing to help is limited -- don't reduce their motivation even more, please.
    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. #26
    Join Date
    Oct 2008
    Location
    Europe
    Posts
    37
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Lightbulb Re: How do I obtain mouse hover/popup functionality in a Qtableview?

    Quote Originally Posted by wysota View Post
    So please restrain yourself from such statements. It's either writing examples at the wiki or answering questions here. The time and will of people willing to help is limited -- don't reduce their motivation even more, please.
    Thanks for the suggestion, i will reimplement a delegate class.

    What statements ??? I think you might have misunderstood me (my fault probably), I was merely speaking about miself, and i never commanded anyone anything...

    cheers

  7. #27
    Join Date
    Aug 2015
    Posts
    3
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: How do I obtain mouse hover/popup functionality in a Qtableview?

    Quote Originally Posted by georgep View Post
    I have subclassed QSqlTableModel in order to have a DecorationRole, no problem there.

    Problem is that when editing (double click on a cell) with My_model the cell turns blank and Remains blank after the cell looses focus.. (of course i dont type anything).
    With QSqlTableModel when i click a cell the contents remain there...
    I get the same behavior with or without my own setData(..) .
    Tried having return QSqlTableModel::setData(index,value,role); in my setdata() but no success....
    Whats the trick? I am speculating that i am loosing the delegates used by qsqltablemodel....
    How did you achieved this... I am trying to do the same but no luck. any hint or advice?

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.