Results 1 to 5 of 5

Thread: QWidget, only draw outline!

  1. #1
    Join Date
    Nov 2012
    Posts
    18
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QWidget, only draw outline!

    Hey,


    is there a way to only draw the outline of a QWidget? I tried to find a example, but could not find one yet.

    I want only to draw a circle with no fill? The innercircle should be transparent!

    Any clues about that?

    Thanks in advance

  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: QWidget, only draw outline!

    setBrush(Qt::NoBrush)
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2012
    Posts
    18
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWidget, only draw outline!

    Hey,

    thanks for your answer, but i am pretty sure that is not that easy.

    I want a QWidget, with an appearance of only an outline.
    Nothing else then the circumference should be visible. No Background, and the inner circle should alos be transparent, e.g.
    show the desktop of the os, or what ever is under the widget.

    I am pretty sure, it can be done with setMask().
    But i still cannot get it.

    Anyone with a good example for making a QWidget with a custom shape as appearance?

    Thanks in advance,

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QWidget, only draw outline!

    Quite apart from the Shaped Clock Example that ships with Qt... this works fine here:
    Qt Code:
    1. class Widget: public QWidget
    2. {
    3. Q_OBJECT
    4. public:
    5. Widget(QWidget *p = 0):
    6. {
    7. resize(400, 400);
    8. QBitmap pixmap(400, 400);
    9. QPainter painter(&pixmap);
    10. painter.fillRect(pixmap.rect(), Qt::color0);
    11. painter.setPen(QPen(Qt::color1, 2));
    12. painter.drawEllipse(QRect(10, 10, 380, 380));
    13. painter.end();
    14. setMask(pixmap);
    15. }
    16. };
    To copy to clipboard, switch view to plain text mode 

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

    lanz (17th May 2013)

  6. #5
    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: QWidget, only draw outline!

    Quote Originally Posted by kinglui987 View Post
    Hey,

    thanks for your answer, but i am pretty sure that is not that easy.
    I'm sure it is as easy as clearly expressing your goal. Read your original post again and see if anyone can understand from it what you want.

    Even what you posted here is not that clear, look:

    I want a QWidget, with an appearance of only an outline.
    QWidget is blank.

    Nothing else then the circumference should be visible.
    QWidget is blank, it has no circumference visible.

    No Background
    set a transparent brush.

    and the inner circle should alos be transparent
    What inner circle?

    I am pretty sure, it can be done with setMask().
    Maybe, hard to say without knowing what you want to do. I would rather put my money on TranslucentBackground attribute.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to get rid of red outline on button last clicked?
    By briankeeney in forum Qt Programming
    Replies: 3
    Last Post: 23rd January 2013, 17:59
  2. QgraphicsSimpleTextItem, QPen outline
    By user14921 in forum Qt Programming
    Replies: 1
    Last Post: 9th October 2011, 16:07
  3. QGraphicTextItem and outline
    By eric_vi in forum Qt Programming
    Replies: 12
    Last Post: 17th October 2010, 20:47
  4. Line Outline?
    By jon-ecm in forum Qt Programming
    Replies: 0
    Last Post: 23rd April 2009, 00:46
  5. Replies: 5
    Last Post: 7th November 2006, 15:01

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.