Results 1 to 6 of 6

Thread: How to remove the dotted rectangle of selection

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: How to remove the dotted rectangle of selection

    Does this hold for QT 4.6? Meaning we cannot get rid of the dotted line in QT 4.6?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: How to remove the dotted rectangle of selection

    You can, and the forum is full of post related to that issue! Use you own delegate, reimplement the paint method and alter option (QStyleOptionViewItem) by removing the desired state, e.g. QStyle::State_HasFocus.

  3. #3
    Join Date
    Mar 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: How to remove the dotted rectangle of selection

    Thanks for your prompt reply. I am using only setStyleSheet to decorate the QPushButton objects as follows:
    Qt Code:
    1. setStyleSheet("QPushButton {background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(255, 255, 255, 255), stop:0.5 rgba(180, 180, 180, 255), stop:0.51 rgba(100, 100, 100, 255), stop:1 rgba(160, 160, 160, 255)); border-radius: 6px;padding: 2px; font: bold}"
    2. "QPushButton::hover {background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(200, 255, 200, 255), stop:0.5 rgba(141, 180, 141, 255), stop:0.51 rgba(78, 100, 78, 255), stop:1 rgba(125, 160, 125, 255));}"
    3. "QPushButton::pressed{background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(125, 160, 125, 255), stop:0.5 rgba(78, 100, 78, 255), stop:0.51 rgba(141, 180, 141, 255), stop:1 rgba(200, 255, 200, 255));}");
    To copy to clipboard, switch view to plain text mode 
    I just need to drop the dotted line when push button widget is selected. Is there a clean way I can use? If you can supply a tiny sample code or a short explanation it would be great.
    Thanks in advance

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: How to remove the dotted rectangle of selection

    As far as I know, there is no way to avoid that dotted rect using style sheets. You have to subclass your button and overwrite the paint event and do the drawing yourself. Use QStylePainter::drawPrimitive() with the right parameters.

  5. The following user says thank you to Lykurg for this useful post:

    moosa (19th April 2010)

Similar Threads

  1. How to paint a selection rectangle on a pixmap?
    By SkripT in forum Qt Programming
    Replies: 6
    Last Post: 8th January 2006, 20:52

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
  •  
Qt is a trademark of The Qt Company.