×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    14

    Creating different shapes button?

    Hi
    I am learnig Qt and in my first aoolication i have to design different shapes buttons like circle, ellipse, i am not getting right direction how to implement them.Please guide me.
    Thanks for your help in advance.

  2. #2
    Registered User
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998

    Re: Creating different shapes button?

    Quote Originally Posted by Niamita View Post
    Hi
    I am learnig Qt and in my first aoolication i have to design different shapes buttons like circle, ellipse, i am not getting right direction how to implement them.Please guide me.
    Thanks for your help in advance.

    You can refer to this article for widgets with irregular shape.

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    14

    Re: Creating different shapes button?

    I am not getting the right direction , can you be more elloborate.

    I tried it by subclassing QPushbutton class and reimplement paint method.


    void MainWindow:aintEvent(QPaintEvent* event)
    {
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);

    QRadialGradient grad(15, 15, 15, 0, 0);
    ///////////////QPixmap map("/:image.png",0,Qt::AutoColor);////////////////////
    //grad.setColorAt(0.0, Qt::white);
    //grad.setColorAt(0.1, Qt::green);
    grad.setColorAt(1.0, Qt::black);
    QBrush brush(grad);
    painter.setBrush(brush);
    painter.drawEllipse(2,2,80,40);
    painter.drawEllipse(20,70,40,40);
    QPixmap m_ButtonIcon;
    m_ButtonIcon.load("/:frame.png");//creates new icon based on icon
    //setIcon(m_ButtonIcon);//sets icon
    //setIconSize(QSize(256, 256));// sets icon size
    //setMask(m_ButtonIcon.createHeuristicMask());//sets mask
    painter.drawPixmap(70,90,20,80,m_ButtonIcon);

    }


    I am successful in creating the shape but when i am trying to apply a image on the ellipse shape then not succeed .
    Please help me what now should done for applying a image on the created shape.
    Last edited by Niamita; 2011-05-03 at 07:23.

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Creating different shapes button?

    If you simply want a different border, and don't mind if the active area of the button is rectangular, just use BorderImage.

  5. #5
    Registered User
    Join Date
    Apr 2011
    Posts
    14

    Re: Creating different shapes button?

    I have to create hexagon shape button.Please guide me how to achieve this.

  6. #6
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Creating different shapes button?


Similar Threads

  1. Creating Customising Button
    By ab in forum Symbian
    Replies: 1
    Last Post: 2007-11-17, 09:33
  2. Creating different versions of single project
    By myohol in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2007-03-14, 08:28
  3. Mapping different menuitems to different Options button on both sides.
    By varshajohn in forum Symbian User Interface
    Replies: 1
    Last Post: 2002-12-04, 05:05
  4. Creating new files in a different folder
    By ACATTAN in forum Symbian User Interface
    Replies: 0
    Last Post: 2002-06-10, 10:04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •