Results 1 to 2 of 2

Thread: Unable to remove Focus from QTableWidget even with setFocusPolicy(Qt::NoF

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    66
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Unable to remove Focus from QTableWidget even with setFocusPolicy(Qt::NoF

    Hi,
    I am new to Qt Environment, i am using a QTablewidget, where i have some some rows and some columns, when the tableWidget was created from QTableWidget, the focus property was set as

    Qt Code:
    1. tableWidget->setFocusPolicy(Qt::NoFocus );
    To copy to clipboard, switch view to plain text mode 

    But still when a cell is clicked on the table, the cell is getting highlighted . Can anyone share as to what can be the reason for the focus not getting cleared from the tableWidget.

    Adding the code


    Qt Code:
    1. {
    2. tableWidget = new QTableWidget(4, 4,RenderScheduleLayout );
    3. QRect rect(40,100,650,200);
    4. tableWidget->setGeometry(rect);
    5. for (int i =0; i < 4; i++)
    6. tableWidget->setColumnWidth(i,50);
    7. for (int i =0; i < 4; i++)
    8. tableWidget->setRowHeight(i,20);
    9.  
    10. tableWidget->setFocusPolicy(Qt::NoFocus)
    11.  
    12. connect(tableWidget,SIGNAL(cellClicked(int,int)),this,SLOT(doSomething(int,int)));
    13. }
    14.  
    15. void Widget::doSomething(int row, int column){
    16.  
    17. QTableWidgetItem *newItem = new QTableWidgetItem(tr(""));
    18. newItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
    19. tableWidget->setItem(row, column, newItem);
    20. tableWidget->clearFocus();
    21. }
    To copy to clipboard, switch view to plain text mode 
    I am also doing a clear focus on this but still the focus on the selected cell is shown, i dont know how to remove the focus as its not being removed using tableWidget->setFocusPolicy(Qt::NoFocus)

    Please help me on this issue.
    Last edited by wysota; 23rd October 2009 at 00:34. Reason: missing [code] tags

Similar Threads

  1. Removing Focus from QTableWidget
    By kapoorsudhish in forum Newbie
    Replies: 2
    Last Post: 22nd October 2009, 14:16
  2. QTableWidget Bug : can't remove row !
    By QAmazigh in forum Qt Programming
    Replies: 7
    Last Post: 17th May 2009, 11:14
  3. How to Compile VTKDesigner2 with Qt?
    By alfredoaal in forum Newbie
    Replies: 0
    Last Post: 5th September 2008, 05:34
  4. Focus of cells in a QTableWidget
    By SailinShoes in forum Qt Programming
    Replies: 4
    Last Post: 9th June 2008, 08:19
  5. Replies: 3
    Last Post: 8th September 2006, 18:54

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.