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!
Forum Updated to NodeBB v4.3 + New Features

Having fixed size for dynamically created buttons!

Scheduled Pinned Locked Moved Solved General and Desktop
qtcreatordynamicbuttonsize
2 Posts 2 Posters 1.0k 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 6 Dec 2017, 08:57 last edited by Kushan 12 Jun 2017, 09:06
    #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
    • V Offline
      V Offline
      VRonin
      wrote on 6 Dec 2017, 10:04 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

      1/2

      6 Dec 2017, 08:57

      • Login

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