Results 1 to 5 of 5

Thread: make an pushbutton round shape

  1. #1
    Join Date
    Dec 2016
    Posts
    10
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default make an pushbutton round shape

    hey guys...i have to make my pushbutton in a rounded shape...when i made it in the ui design by using border-radius: 10px; it worked,but i cannot click the rounded button when i run the ui.
    the button must be toggled tooo.when i click on one window it must be pressed in the other too..(i.e) the clicked buton must be disabled in the other window..which must signify that i had already clicked the button on the previous screen..

    pls help me with a sample code..

  2. #2
    Join Date
    Dec 2016
    Posts
    10
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: make an pushbutton round shape

    GOT IT

    USED THIS ONE
    #
    ui->pushButton_6->setText("7");
    ui->pushButton_7->setText("6");
    ui->pushButton_8->setText("5");
    ui->pushButton_4->setText("1");
    ui->pushButton_5->setText("8");
    ui->pushButton_9->setText("4");
    ui->pushButton_10->setText("3");
    ui->pushButton_11->setText("2");
    ui->pushButton_6->setFixedHeight(20);
    ui->pushButton_7->setFixedHeight(20);
    ui->pushButton_8->setFixedHeight(20);
    ui->pushButton_4->setFixedHeight(20);
    ui->pushButton_5->setFixedHeight(20);
    ui->pushButton_9->setFixedHeight(20);
    ui->pushButton_10->setFixedHeight(20);
    ui->pushButton_11->setFixedHeight(20);
    ui->pushButton_6->setFixedWidth(20);
    ui->pushButton_7->setFixedWidth(20);
    ui->pushButton_8->setFixedWidth(20);
    ui->pushButton_4->setFixedWidth(20);
    ui->pushButton_5->setFixedWidth(20);
    ui->pushButton_9->setFixedWidth(20);
    ui->pushButton_10->setFixedWidth(20);
    ui->pushButton_11->setFixedWidth(20);
    QRect *rect = new QRect(0,0,20,20);
    QRegion* region = new QRegion(*rect,QRegion::Ellipse);
    ui->pushButton_6->setMask(*region);
    ui->pushButton_7->setMask(*region);
    ui->pushButton_8->setMask(*region);
    ui->pushButton_4->setMask(*region);
    ui->pushButton_5->setMask(*region);
    ui->pushButton_9->setMask(*region);
    ui->pushButton_10->setMask(*region);
    ui->pushButton_11->setMask(*region);
    #

  3. #3
    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: make an pushbutton round shape

    Don't allocate the rect and region on the heap, or deleted them after you used them.

    Otherwise you will leak memory.

    Cheers,
    _

  4. The following user says thank you to anda_skoa for this useful post:

    CAFFRY (30th December 2016)

  5. #4
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: make an pushbutton round shape

    You can try like this:
    Qt Code:
    1. QPixmap pixmapLogin(":/new/prefix1/Resources/login_released.png");
    2. QSize imagesize = pixmapLogin.size();
    3. ui->LoginButton->setFixedSize(imagesize);
    4. ui->LoginButton->setMask(pixmapLogin.mask());
    5. ui->LoginButton->setCursor(QCursor(Qt::PointingHandCursor));
    To copy to clipboard, switch view to plain text mode 

  6. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: make an pushbutton round shape

    You can try like this
    And how does this answer the OP's question about making round buttons? Please don't post irrelevant answers to old questions. It makes you look bad and gives misleading advice.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. handle of Qslider in round shape using stylesheet
    By vivek.panchal in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2012, 08:13
  2. QPushButton -- Round shape
    By kishore7771 in forum Qt Programming
    Replies: 6
    Last Post: 15th February 2010, 13:40
  3. How to creat different shape of pushbutton?
    By Manohar in forum Qt Tools
    Replies: 16
    Last Post: 28th March 2008, 15:16
  4. small round pushbutton
    By sm in forum Newbie
    Replies: 3
    Last Post: 5th February 2008, 10:08
  5. shape of a pushbutton
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 16th August 2007, 09:58

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.