Results 1 to 3 of 3

Thread: please help me .. How Disable Move Focus / Cursor when Invalid input value ?

  1. #1
    Join Date
    Nov 2008
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default please help me .. How Disable Move Focus / Cursor when Invalid input value ?

    Hi All,
    Please Helpme
    I try create QtableWidget and QitemDelegate . ( QLineEdit )
    how stop move cursor / focus when invalid input ? in QlineEdit
    ??

  2. #2
    Join Date
    Jul 2009
    Posts
    139
    Thanks
    13
    Thanked 59 Times in 52 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: please help me .. How Disable Move Focus / Cursor when Invalid input value ?

    Probably, the easiest is to just setFlags on all the other cells:
    Qt Code:
    1. void DisableAllExceptOne(QTableWidget & tbl, const QTableWidgetItem & allowed)
    2. {
    3. for (int i = 0; i < tbl.rowCount(); i++)
    4. for (int j = 0; j < tbl.columnCount(); j++)
    5. if (!(tbl.item(i, j)->row() == allowed.row() &&
    6. tbl.item(i, j)->column() == allowed.column()))
    7. tbl.item(i, j)->setFlags(Qt::NoItemFlags);
    8. }
    9.  
    10. int main(int argc, char * argv[])
    11. {
    12. QApplication a(argc, argv);
    13.  
    14. tbl.setRowCount(1);
    15. tbl.setColumnCount(3);
    16.  
    17. QTableWidgetItem * item1 = new QTableWidgetItem("ONE");
    18. tbl.setItem(0, 0, item1);
    19.  
    20. QTableWidgetItem * item2 = new QTableWidgetItem("TWO");
    21. tbl.setItem(0, 1, item2);
    22.  
    23. QTableWidgetItem * item3 = new QTableWidgetItem("THREE");
    24. tbl.setItem(0, 2, item3);
    25.  
    26. DisableAllExceptOne(tbl, *item1);
    27. tbl.show();
    28.  
    29. return a.exec();
    30. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Nov 2008
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: please help me .. How Disable Move Focus / Cursor when Invalid input value ?

    great i'll try ..

Similar Threads

  1. QDateTimeEdit (QTimeEdit, QDateEdit) invalid input
    By Kumosan in forum Qt Programming
    Replies: 10
    Last Post: 15th June 2012, 13:21
  2. how to use Qcursor to move the mouse cursor
    By jack_shen in forum Newbie
    Replies: 3
    Last Post: 22nd March 2010, 08:20
  3. can't move cursor
    By felix_tang in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 10:36
  4. QGraphicsItem and focus for key input
    By fossill in forum Qt Programming
    Replies: 2
    Last Post: 9th February 2007, 20:13
  5. Replies: 4
    Last Post: 31st August 2006, 13:11

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.