Page 1 of 2 12 LastLast
Results 1 to 20 of 25

Thread: Skinned dialogs

  1. #1
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Skinned dialogs

    Hi all,
    probably my question is very platform dependent but I'd like to know how can I have a skinned frame for my dialogs, just like Microsoft Messenger.
    Thanks for any tips on that
    Bye

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Skinned dialogs

    This is not platform specific - try to subclass QStyle. The style example shows how to implement norwegian wood, try starting from that.

  3. #3
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Skinned dialogs

    thanks, I already use QStyle for customize widgets but I guess there's no way to customize application frame.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

  5. #5
    Join Date
    Aug 2006
    Posts
    83

    Default Re: Skinned dialogs

    There is a way. U have to use native support and in there draw primitive element PE_CustomBase and than in drawPrimitive draw anything on it.

  6. #6
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Skinned dialogs

    thanks for answering, this sounds very interesting to me, but I cannot figure it out how to do that.
    One way could be to draw my window frameless and the draw by myself the window caption, but maybe there's a better way to do that
    thanks,
    bye

  7. #7
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Skinned dialogs

    One way could be to draw my window frameless and the draw by myself the window caption, but maybe there's a better way to do that
    This is how microsoft does it. (Windows media player, Live messenger, Office 12, etc). So still a dirty hack, but now endorsed by microsoft!

  8. #8
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Skinned dialogs

    Thanks for your answer, I'll try to do that. However I thought there someone had already tried to have such kind of dialogs in Qt.
    Bye

  9. #9
    Join Date
    Feb 2007
    Posts
    28
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Skinned dialogs

    Hi, Did you find a solution, im trying to do the same thing, with resizing support?
    Any example that i could find to do this?

  10. #10
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Skinned dialogs

    Making your dialogs frameless, then drawing your own frame, is the best way. I have never done this directly, but I have done similar things writing an X11 window manager. Here's a brief overview:

    1) Create a widget called WindowFrame
    2) Give it a 3x3 grid layout
    3) Put your dialog in the center
    4) In WindowFrame:aintEvent(), draw corner pixmaps in the corner, and tilable edge pixmaps on the edges
    5) To make it resizable, implement mousePressEvent() and mouseMoveEvent()

    The inclusion of titlebar and title buttons I leave an an exercise to the reader.

  11. #11
    Join Date
    Feb 2007
    Posts
    28
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Skinned dialogs

    Hi, Thanks for the suggestions. I did what you say and it work.
    The only problem that i had now is clipping the transparent part of the borders, so its actually round, and not black(it show transparent color as black)
    I read that i can accomplish this with a mask, but i don't know how to add a mask to the widget, just to the particular corners.
    All the different borders are separate images, and i have to join them some how, and then apply the mask to the widget
    Any help with this???
    thanks in advance!
    CJC

  12. #12
    Join Date
    Feb 2007
    Posts
    28
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Skinned dialogs

    Someone can help on this plz?

  13. #13
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Skinned dialogs

    Quote Originally Posted by PiXeL16 View Post
    The only problem that i had now is clipping the transparent part of the borders, so its actually round, and not black(it show transparent color as black)
    I read that i can accomplish this with a mask, but i don't know how to add a mask to the widget, just to the particular corners.
    All the different borders are separate images, and i have to join them some how, and then apply the mask to the widget
    Any help with this???
    You will need to create the widget's bitmap mask out of the borders' masks. Set the size of the bitmap to the size of the widget, then "draw" in the corner and edge bitmap masks.

    Adding the mask to the widget is the same as adding it to a pixmap: QWidget::setMask()

  14. #14
    Join Date
    Feb 2007
    Posts
    28
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Skinned dialogs

    I thanks, i had try this but i dont know why is not working.
    I create a widget and add 9 frames, 8 for all the borders and 1 for the widget.
    Then I set the borders as background images to their specific frame.
    Then I try to create my pixmap buffering all the borders
    Here is my code.



    Qt Code:
    1. QPixmap buffer(_mainWidget->size());
    2.  
    3. QPainter painter(&buffer);
    4.  
    5. painter.drawPixmap(_uiMainWidget->upperLeftFrame->frameRect(), QPixmap(":pics/bg/upperLeftFrame.png"),
    6. _uiMainWidget->upperLeftFrame->frameRect());
    7. ...
    8. painter.drawPixmap(_uiMainWidget->leftFrame->frameRect(),
    9. QPixmap(":pics/bg/leftFrame.png"),
    10. _uiMainWidget->leftFrame->frameRect());
    To copy to clipboard, switch view to plain text mode 


    THe result here is that all my border images are drawn staked in the upper left side of the pixmap. And not in the correct position where the frames are.
    Where could be wrong here? Are im using wrong the drawpixmap funtionality or missing something?
    Any help will be much appreciated
    Thanks
    CJC

  15. #15
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Skinned dialogs

    Have you tried Style sheets?

  16. #16
    Join Date
    Feb 2007
    Posts
    28
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Skinned dialogs

    How can sc help with the problem of the images? that i specified before?

  17. #17
    Join Date
    Feb 2007
    Posts
    28
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Skinned dialogs

    HI, i kind of fix my issue.
    I should use .geometry and not frameRect()
    Thanks for all the help
    CJC

  18. #18
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Skinned dialogs

    could anyone post the code for resizing the frameless widget?
    i tried this, but till today i've no idea how to implement this by myself...

  19. #19
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Skinned dialogs

    Quote Originally Posted by kernel_panic View Post
    could anyone post the code for resizing the frameless widget?
    i tried this, but till today i've no idea how to implement this by myself...
    How about QSizeGrip?
    J-P Nurmi

  20. #20
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Skinned dialogs

    thanks
    one question: with qsizegrip ic can only resize to bottom-left, how can i let it resize to left or right or bottom only?

Similar Threads

  1. Using special characters in QT dialogs
    By hvengel in forum Qt Tools
    Replies: 2
    Last Post: 10th April 2007, 00:32
  2. How to chain dialogs
    By seneca in forum Qt Programming
    Replies: 12
    Last Post: 14th January 2006, 22:04

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.