Results 1 to 6 of 6

Thread: QScrollBar + setToolTip speed on display ... to slow

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QScrollBar + setToolTip speed on display ... to slow

    I have write my own QSqlTableModel && QSqlRelationalDelegate (date edit)
    If model update a query QScrollBar go to int 0 now i have reimplement a function to save
    the last scroll ... & after 2 msec. i move QScrollBar to this position...
    this run ok .... but if i display a ToolTip from Line nr. on QScrollBar this tips gomming after
    1 or 2 sek. .. Question How i can make tis tooltips faster like Calc from openoffice 2?
    Is here an event to handle?.....



    Qt Code:
    1. signals:
    2. public slots:
    3. /* incomming last scroll position from table scroll int like row nr + 1 */
    4. void RamScroll( int finder )
    5. {
    6. scroller->setToolTip(tr("Line nr. %1").arg(finder + 1));
    7. if (permission) {
    8. lastscrollpos = finder;
    9. }
    10. }
    11. /* incomming emit sql update from model after update go to last line */
    12. void IncommingUpdate( bool err , QString lastqueryupdate , int lastline )
    13. {
    14. permission = false;
    15. oneditline = lastline;
    16. ///////////qDebug() << "### log sql " << lastscrollpos << " " << lastqueryupdate << " res->" << err;
    17. /* wait a small piece by update model go line scroll 0 */
    18. QTimer::singleShot(2, this, SLOT(ResetPermission()));
    19. }
    20. void ResetPermission() {
    21. scroller->setValue(lastscrollpos);
    22. tabi->setAlternatingRowColors(true);
    23. tabi->resizeColumnsToContents();
    24. tabi->selectRow( oneditline );
    25. permission = true;
    26. }
    27. /* go to next limit x paintButton befor model */
    28. void next()
    29. {
    30. int summrow = summRow() ;
    31. showfrom = showfrom + limitfixrow;
    32. paintButton();
    33. model = new Beruf_model_A(db,showfrom,limitfixrow);
    34. tabi->setModel(model);
    35. connect( model , SIGNAL(OnUpdate(bool,QString,int)), this, SLOT(IncommingUpdate(bool,QString,int)));
    36. scroller->setValue(0);
    37. }
    38. /* go to prev (if button enable) limit x paintButton befor model */
    39. void prev()
    40. {
    41. int summrow = summRow() ;
    42. showfrom = showfrom - limitfixrow;
    43. paintButton();
    44. model = new Beruf_model_A(db,showfrom,limitfixrow);
    45. tabi->setModel(model);
    46. connect( model , SIGNAL(OnUpdate(bool,QString,int)), this, SLOT(IncommingUpdate(bool,QString,int)));
    47. scroller->setValue(0);
    48. }
    To copy to clipboard, switch view to plain text mode 
    note:
    This text is paste from window XP .... Not from ubuntu firefox .... buggi \n\n
    Last edited by patrik08; 25th February 2007 at 19:49. Reason: Append note last line

  2. #2
    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: QScrollBar + setToolTip speed on display ... to slow

    I'd say that not resetting the model in the first place would be the easiest way to obtain your goal

    Just don't inherit the model but embed it inside your own. Then when you do select() in the source model, simply update the model you expose. You can forward the rest of the calls from your "proxy" to the source model. This way you won't lose scrolling and selection at all.

    You can try doing the same by subclassing the sql model and reimplementing select() but it might prove a lot harder.

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QScrollBar + setToolTip speed on display ... to slow

    Quote Originally Posted by wysota View Post
    I'd say that not resetting the model in the first place would be the easiest way to obtain your goal
    .
    I dont have a select ..... if i make select by my own refresh() if i make select i have 1000 of row and i like only 100 .... and i testet setfilter (limit xx) ..... the way not running

    Qt Code:
    1. Beruf_model_A::Beruf_model_A( QSqlDatabase dbin , int startat , int limit )
    2. {
    3. db = dbin;
    4. setTable("table");
    5. setEditStrategy(QSqlTableModel::OnRowChange);
    6. limitrow = limit;
    7. fromrow = startat;
    8. updatepass = 0;
    9. ///////select();
    10. refresh();
    11. }
    12.  
    13.  
    14. void Beruf_model_A::refresh()
    15. {
    16. QString sfsql;
    17. sfsql = QString("SELECT * FROM table LIMIT %1,%2")
    18. .arg(fromrow)
    19. .arg(limitrow);
    20. setQuery(sfsql);
    21. setHeaderData(0, Qt::Horizontal, QObject::tr("fielda"));
    22. ...../* only header */
    23.  
    24. }
    25.  
    26. bool Beruf_model_A::setData(const QModelIndex &index, const QVariant &value, int role )
    27. {
    28. if (index.column() == 2 || index.column() > 12 ) {
    29. return false;
    30. }
    31. QModelIndex primaryKeyIndex = QSqlQueryModel::index(index.row(), 2);
    32. int id = data(primaryKeyIndex).toInt();
    33. int lasteditingline = index.row();
    34. bool ok;
    35. QString saxi;
    36. if (index.column() == 0) {
    37. saxi = QString("update table set fielda = '%1' where ID = %2").arg(value.toString().toUpper()).arg(id);
    38. } else if (index.column() == 1) {
    39. saxi = QString("update table set fieldb = '%1' where ID = %2").arg(value.toInt()).arg(id);
    40. /* .......else if 10 field.......... */
    41. QSqlQuery query(saxi,db);
    42. ok = query.exec();
    43. refresh(); /* display new value */
    44. updatepass++;
    45. qDebug() << "### query " << query.lastQuery() << " fatto " << ok ;
    46. emit OnUpdate(ok,query.lastQuery(),lasteditingline); /* if db2 is active send sincro */
    47. return ok;
    48. }
    To copy to clipboard, switch view to plain text mode 

    if i dont refresch refresh() model it display old value of field....

    i suppose i have subclass a readonly model ....???


    Qt Code:
    1. class Beruf_model_A : public QSqlTableModel
    2. {
    3. Q_OBJECT
    4. public:
    5. Beruf_model_A( QSqlDatabase dbin , int startat , int limit );
    6. Qt::ItemFlags flags(const QModelIndex &index) const;
    7. bool setData(const QModelIndex &index, const QVariant &value, int role);
    8. inline int GetPassage() const { return updatepass; }
    9. signals:
    10. void OnUpdate( bool yes , QString sqlexc , int line );
    11. private:
    12. QString sql_Quote( QString xml );
    13. int updatepass;
    14. int limitrow;
    15. int fromrow;
    16. void refresh();
    17.  
    18. };
    19.  
    20. /* date edit QDateTimeEdit */
    21. class TabDelegate : public QSqlRelationalDelegate
    22. {
    23. Q_OBJECT
    24.  
    25. public:
    26. TabDelegate( QObject *parent = 0);
    27. void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    28. QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    29. void setEditorData(QWidget *editor, const QModelIndex &index) const;
    30. void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
    31. private slots:
    32. private:
    33. };
    34.  
    35.  
    36. /* QWidget wo call table */
    37.  
    38. oneditline = 0;
    39. showfrom = 0;
    40. limitfixrow = 100;
    41. db = dbin;
    42. model = new Beruf_model_A(dbin,showfrom,limitfixrow);
    43. gridLayout = new QGridLayout(this);
    44. gridLayout->setSpacing(6);
    45. gridLayout->setMargin(9);
    46. permission = true;
    47.  
    48. tabi = new QTableView(this);
    49. tabi->setModel(model);
    50. tabi->setItemDelegate(new TabDelegate(tabi));
    51. tabi->setAlternatingRowColors(true);
    52. tabi->resizeColumnsToContents();
    53. scroller = tabi->verticalScrollBar();
    To copy to clipboard, switch view to plain text mode 

  4. #4
    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: QScrollBar + setToolTip speed on display ... to slow

    Quote Originally Posted by patrik08 View Post
    I dont have a select .....
    Sure you have. Every QSqlTableModel has one The point is to omit the default call (be it select() or setQuery() ), fetch the data yourself and sync the two models manually.

    if i dont refresch refresh() model it display old value of field....
    Because you have to update the model... just without calling select or setQuery, as they reset the model. Use insertRow, insertColumn, removeRow, removeColumn and setData instead.

    i suppose i have subclass a readonly model ....???
    No, nobody said that.

  5. #5
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QScrollBar + setToolTip speed on display ... to slow

    Quote Originally Posted by wysota View Post
    Sure you have. Every QSqlTableModel has one The point is to omit the default call (be it select() or setQuery() ), fetch the data yourself and sync the two models manually.
    .
    OK ... if i make a default select and not !refresh on my own query...
    How i set setQuery() && set filter( limit 100 row ) to grab only 100 line and not >1000? this setLimit() qt4 dont'have! not found on doc && not on book QT4 Molkentin && Jasmin books... && kde qt-copy demo or example && qt4 normal....

  6. #6
    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: QScrollBar + setToolTip speed on display ... to slow

    Try:
    Qt Code:
    1. setFilter("1 LIMIT 0, 100");
    To copy to clipboard, switch view to plain text mode 

    Anyway that doesn't solve the original problem, does it?

  7. The following user says thank you to wysota for this useful post:

    patrik08 (26th February 2007)

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.