Results 1 to 8 of 8

Thread: Design buttons with custom shapes

  1. #1
    Join Date
    Apr 2015
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Design buttons with custom shapes

    Hello everyone!
    I am trying to desing a sequence of custom buttons with arrow shape but I could not find the way. I need something like the buttons that you can see in the next picture in order to manage the workflow of my program and guide the user through it.
    stepButtons.jpg

    Any help or suggestion is welcome.
    Thanks for your help.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Design buttons with custom shapes

    Do you want Buttons or Progress Indicators?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Apr 2015
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Design buttons with custom shapes

    Hello Santosh Reddy.
    I want buttons. The main idea is that each button will launch a wizard dialog to perform each step. Then, when this step is finished the next button will be enabled. So the buttons should change its color and being enabled sequentially guiding the user throught the workflow.

    Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Design buttons with custom shapes

    My approach would be to do this as a custom widget.
    Either direct painting or with a graphicsview and arrow shaped items.

    Cheers,
    _

  5. #5
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Design buttons with custom shapes

    Here is one approach using QPushButton Button, see if it fits your need

    CustomBottuns.jpg


    Qt Code:
    1. QWidget widget;
    2.  
    3. for(int i = 0; i < 4; i++)
    4. {
    5. QPushButton * button = new QPushButton(QString("Step %1").arg(i + 1), &widget);
    6.  
    7. if((i == 0) or (i == 2))
    8. {
    9. button->setEnabled(true);
    10. }
    11. else
    12. {
    13. button->setEnabled(false);
    14. }
    15.  
    16. QPixmap pixmap;
    17.  
    18. if(i == 0)
    19. {
    20. pixmap = QPixmap("C:/Left.png");
    21. }
    22. else if(i == 3)
    23. {
    24. pixmap = QPixmap("C:/Right.png");
    25. }
    26. else
    27. {
    28. pixmap = QPixmap("C:/Mid.png");
    29. }
    30.  
    31. button->setFixedSize(110,68);
    32.  
    33. button->setMask(pixmap.mask());
    34.  
    35. button->setGeometry((110 - 40) * i, 0, 110, 68);
    36. }
    37.  
    38. widget.show();
    To copy to clipboard, switch view to plain text mode 

    Here are the mask files (some quick drawing using GIMP)

    Left.png

    Mid.png

    Right.png
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  6. #6
    Join Date
    Apr 2015
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Design buttons with custom shapes

    Thanks! It looks great but I am having a problem in the line "button->setMask(pixmap.mask());". It is the next error:

    error: C2027: use of type 'QBitmap' undefined.

    I don't know how to solve it.
    Thanks for your help


    SOLVED! I need to include QBitMap to use this method.
    Thanks for your help!!
    Last edited by LuisLoez89; 22nd April 2015 at 15:34.

  7. #7
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Design buttons with custom shapes

    I used QPixmap not QBitmap.

    Does the sample code work in your setup?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  8. #8
    Join Date
    Apr 2015
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Design buttons with custom shapes

    Yes I am using QPixmap too but it seems that you need include QBitmap to use the .mask() method.

    It is working fine! I need make some changes but your example was really usefull to understand the use of the masks.

    Thanks

Similar Threads

  1. Custom Design ... no clean way?
    By MCSpy in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2014, 03:08
  2. How to design a custom videoOutput?
    By stereoMatching in forum Qt Quick
    Replies: 1
    Last Post: 16th December 2013, 15:00
  3. Custom look for buttons
    By harvey_slash in forum Newbie
    Replies: 0
    Last Post: 3rd October 2013, 13:18
  4. Replies: 2
    Last Post: 19th April 2010, 12:49
  5. Custom buttons problem
    By giotto in forum Qt Programming
    Replies: 7
    Last Post: 7th February 2008, 21:56

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
  •  
Qt is a trademark of The Qt Company.