Results 1 to 3 of 3

Thread: Custom-Shaped Widget

  1. #1
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation Custom-Shaped Widget

    Hi all,
    I need some help on creating a widget shaped with an icon I choosed, and with the same icon displayed.
    For the first part, all is simple:
    Qt Code:
    1. ...
    2. QDialog myDialog;
    3. QPixmap myPixmap = QPixmap( QString::fromUTF8(":/img/logo.svg") );
    4. myDialog.setMask( pixmap.mask() );
    To copy to clipboard, switch view to plain text mode 
    Now, how can I embed the same .svg icon inside the shaped dialog, in order to display it ??
    Or, there is a simpler way to do it ??
    Thanks in advance, cheers !

  2. #2
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom-Shaped Widget

    Use QLabel as top level window
    Qt Code:
    1. QLabel myDialog;
    2. QPixmap myPixmap = QPixmap( QString::fromUTF8(":/img/logo.svg") );
    3. myDialog.setMask( pixmap.mask() );
    4. myDialog.setPixmap( pixmap );
    To copy to clipboard, switch view to plain text mode 

    Be sure that the objects will be on place where they will not be deleted because of out of scope reason or else make them pointers.

  3. The following user says thank you to The Storm for this useful post:

    [Po]lentino (9th April 2009)

  4. #3
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Custom-Shaped Widget

    Omg, I never figured to use a QLabel to reach my goal !!!
    Thank you a lot, The Storm !!

Similar Threads

  1. Problem building application with custom widget
    By Uthar in forum Installation and Deployment
    Replies: 6
    Last Post: 19th January 2009, 18:57
  2. Custom Widget - First Steps
    By sekatsim in forum Qt Programming
    Replies: 8
    Last Post: 26th June 2008, 18:19
  3. resizing events of a custom widget in a layout
    By Rooster in forum Qt Programming
    Replies: 7
    Last Post: 16th February 2008, 11:52
  4. Custom widget
    By zorro68 in forum Qt Programming
    Replies: 7
    Last Post: 28th January 2008, 15:06
  5. custom plug-in widget in another custom plug-in widget.
    By MrGarbage in forum Qt Programming
    Replies: 6
    Last Post: 27th August 2007, 16:38

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.