Results 1 to 7 of 7

Thread: Dialog Mask

  1. #1
    Join Date
    Jun 2009
    Location
    Abu Dhabi
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Dialog Mask

    Hi Friends,

    I checked some of the threads, but in that thread they only discussed about how to remove(mask) the background of the widget.

    But i need bring the qdialog the irregular shape that depends on the image we set as backgroud for the widget.

    For example i have an image like iphone..my qdialog should be look like iphone and make the remaining thing as tranparent.

    Help please.....

  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: Dialog Mask

    Use the image as the mask or set a "translucent background" attribute on your dialog so that only the areas you paint yourself are opaque.
    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
    Jun 2009
    Location
    Abu Dhabi
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dialog Mask

    Thank for ur quick reply zen,

    i need further clarification...

    I have a QDialog.ui ...in that stylesheet property for the QFrame i was set

    Qt Code:
    1. {
    2. background-image: url(:/images/messagebox.png) no-repeat;
    3. }
    To copy to clipboard, switch view to plain text mode 

    and in my QDialog constructor

    Qt Code:
    1. QPixmap pixmap(":/images/messagebox.png");
    2.  
    3. ui->frame->setMask(pixmap.mask());
    4. QRegion reg(frameGeometry());
    5. reg-=QRegion(geometry());
    6. reg+=childrenRegion();
    7. setMask(reg);
    To copy to clipboard, switch view to plain text mode 


    but i got an error

    dialog.cpp: In constructor ‘Dialog:ialog(QWidget*)’:
    dialog.cpp:12: error: invalid use of incomplete type ‘struct QBitmap’
    /opt/qtsdk-2010.05/qt/include/QtGui/qwindowdefs.h:77: error: forward declaration of ‘struct QBitmap’
    make: *** [dialog.o] Error 1

  4. #4
    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: Dialog Mask

    Qt Code:
    1. #include <QBitmap>
    To copy to clipboard, switch view to plain text mode 

    But this will not work. You need to set the mask on the top-level widget only (the dialog, not the frame that's in it).
    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.


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

    thahir1986 (25th October 2010)

  6. #5
    Join Date
    Jun 2009
    Location
    Abu Dhabi
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dialog Mask

    Thanks..It works.

    But one silly question finally..

    I want to remove the title window of the QDialog, for that i did give the

    Qt Code:
    1. setAttribute(Qt::FramelessWindowHint, true);
    To copy to clipboard, switch view to plain text mode 

    but again i got an error like,

    dialog.cpp:14: error: no matching function for call to ‘Dialog::setAttribute(Qt::WindowType, bool)’
    /opt/qtsdk-2010.05/qt/include/QtGui/qwidget.h:607: note: candidates are: void QWidget::setAttribute(Qt::WidgetAttribute, bool)
    make: *** [dialog.o] Error 1


    aahh..i want to learn qt through, but i can't.

  7. #6
    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: Dialog Mask

    It's a hint not an attribute.

    aahh..i want to learn qt through, but i can't.
    I suggest to learn C++ first.
    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.


  8. #7
    Join Date
    Jun 2009
    Location
    Abu Dhabi
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dialog Mask

    Quote Originally Posted by wysota View Post
    I suggest to learn C++ first.
    U r correct indeed.. i need learn that first indeed...Could tell me which is the best book to learn c++ crystal clear...?

Similar Threads

  1. QLineedit mask
    By sudhansu in forum Qt Programming
    Replies: 11
    Last Post: 12th March 2010, 12:10
  2. Qt 4 expanded mask
    By bunjee in forum Qt Programming
    Replies: 4
    Last Post: 7th May 2008, 14:21
  3. help with.. numeric mask....
    By ocascante in forum Qt Tools
    Replies: 1
    Last Post: 12th July 2007, 09:53
  4. MainWindow mask
    By SirBabyface in forum Qt Programming
    Replies: 0
    Last Post: 11th July 2007, 15:12
  5. Problem with mask and validation
    By gunhelstr in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2006, 08:07

Tags for this Thread

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.