Results 1 to 2 of 2

Thread: Elegant way of getting if element is focused in function QGraphicsItem::shape()

  1. #1
    Join Date
    Jul 2011
    Posts
    22
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Elegant way of getting if element is focused in function QGraphicsItem::shape()

    hello,

    i can learn if my object inherits from QGraphicsItem is focused in paint method:

    Qt Code:
    1. void MyQGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
    2. {
    3. if (option->state & QStyle::State_HasFocus) {
    4. //if focus some shape
    5.  
    6. } else {
    7. //if no focus another shape
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    but i must click it and the shape must change whether it is focused or not.
    how can i get if focused information in

    Qt Code:
    To copy to clipboard, switch view to plain text mode 

    method in an appropriate way?
    I think to declare a global variable but i do not like this idea.
    thanks

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Elegant way of getting if element is focused in function QGraphicsItem::shape()

    strange: why you couldn't find: QGraphicsItem::hasFocus

Similar Threads

  1. QlineEdit is not showing the Current Focused Widget,
    By savaliya_ambani in forum Qt for Embedded and Mobile
    Replies: 12
    Last Post: 18th December 2010, 13:45
  2. Raising the MainWindow to active/focused state
    By bmahf in forum Qt Programming
    Replies: 0
    Last Post: 5th November 2009, 22:15
  3. Most elegant Qt Multidimentional array
    By philwinder in forum Qt Programming
    Replies: 3
    Last Post: 15th June 2008, 10:38
  4. Elegant Qt's future?
    By magland in forum General Discussion
    Replies: 5
    Last Post: 12th June 2007, 21:42
  5. Replies: 4
    Last Post: 13th April 2007, 11:16

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.