Having fixed size for dynamically created buttons!



  • In my qt c++ application buttons are created dnamically! When the number of buttons are different the size of the buttons are also diffrent! I want to have a fixed size for the buttons!

    void NewOrders::on_pushButton_clicked(){

    QString LIst;
    List<<"Hello"<<"John";

    for(int i=0;i<List.size();i++){
    QString Name= QString::number(i);
    f3 = new QFrame();
    c= new QPushButton();
    c->setText("Set "+List[i]);
    c->setObjectName("Button"+Name);
    ui->horizontalLayout->addWidget(c);

    }
    }

    Here 2 buttons are created since List has 2 elements! But if I insert another element to the List 3 buttons are created but the size of a button in the 2 situations is different! How can I have a fixed size for the buttons for both the situations?



  • f3 = new QFrame();

    ???

    How can I have a fixed size for the buttons for both the situations?

    c->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.