Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Having fixed size for dynamically created buttons!
QtWS25 Last Chance

Having fixed size for dynamically created buttons!

Scheduled Pinned Locked Moved Solved General and Desktop
qtcreatordynamicbuttonsize
2 Posts 2 Posters 984 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kushan
    wrote on last edited by Kushan
    #1

    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?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      f3 = new QFrame();

      ???

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

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

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved