Results 1 to 9 of 9

Thread: Suggestions in giving to my application a cool look

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Jan 2006
    Location
    Cambridge, MA
    Posts
    32
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 7 Times in 6 Posts

    Default Re: Suggestions in giving to my application a cool look

    SkripT,

    Alrighty you can easily make this UI in Qt. You will be using masks to make non-rectangular widgets. Making you UI is an easier in Qt 4.1 and the following is Qt 4.1 based.

    Basically you want a base dialog with an elaborate pixmap drawn on ground and a mask set to let the windowing system know what shape you would like to have. A mask is a 1bit deep pixmap (pixels can be on or off, 1 or 0). If you use a PNG with index transparency this will be done automatically or you can have Qt create on from your pixmap by trying to stip out the background.

    The following of code off the top of my head so do not expect it to "just work" with a cut and paste.

    You will subclass QDialog and in the resizeEvent you will do the following
    1) Resize your background image
    2) Call QBitmap bm = myPixmap.createHueristicMask(); // Not need if using PNG
    2) If usiing PNG you could just do QBitmap bm(myPixmap)
    3) call setMask(myPixmap)
    4) Calulate how many pixels to "step in" to avoid the transparent space and the edges of the book and call setContentsMargins(int,int,int,int) with these values. This will allow you to use regular layouts.

    In paintEvent:
    1) Make a painter
    2) call drawPixmap(... myPixmap);


    That should get you a window that looks like the book. If using Qt 4.1 and above childern effectively recieve snapshots of the parent for a background for "true transparency". So you can just make an instance of the above class, create childern and layouts as you see fit and you should be well on your way.

    If setContents marginis set correctly the toplevel layout of this book class will only allocate space defint by the readctangle "Widget1" + "Widget2" + Space in the middle. You can use two widgets for layout in your implementation, but since those blank container QWidgets will get snapshots for thier backgrounds that is a simple implementation detail.

    --Justin Noel
    justin@ics.com

  2. The following user says thank you to Glitch for this useful post:

    SkripT (2nd May 2006)

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.