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. [Split] setting buttons size
Forum Updated to NodeBB v4.3 + New Features

[Split] setting buttons size

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 31.7k Views 1 Watching
  • 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.
  • G Offline
    G Offline
    gogoi
    wrote on last edited by
    #1

    hello sigrid

    its working now..u r right enum doesnt cause any problem..thanks for your suggestion..

    now i have one more query to ask you..actually i want to set width and height of a buttons in codding for that i have used following code..
    @for(int i=0;i<5;i++) {
    for(int j=0;j<5;j++) {
    but[i][j]=new QPushButton();
    but[i][j]->setMinimumWidth(68);
    but[i][j]->setMinimumHeight(60);
    but[i][j]->setStyleSheet("background-image: url(:/images/but-active.png);");

    }}@

    here height is set but width is not set..can you please suggest me why..any option to change the height and width of a buttons..similar to the size of image set as bacground image of the buttons

    [EDIT: split off to a new topic, Volker]

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sigrid
      wrote on last edited by
      #2

      In the future, can you please post new questions in new threads?

      You can change the size of QPushButtons in different ways. You can reimplement its "sizeHint()":http://doc.qt.nokia.com/4.7/qwidget.html#sizeHint-prop to return the size you prefer and give it a suitable sizepolicy, you can give it a "fixedSize()":http://doc.qt.nokia.com/4.7/qwidget.html#setFixedSize or you can give it a minimum size. Setting a minimum width and minimum height causes the QPushButton to have the requested minimum size for me in the example below. Does my example reproduce the problem you are having? If not, can you modify it so that it does?

      @#include <QtGui>

      int main(int argc, char** argv)
      {
      QApplication app(argc, argv);
      QWidget wid;
      QPushButton *button = new QPushButton(&wid);
      button->setMinimumWidth(68);
      button->setMinimumHeight(60);
      QVBoxLayout *layout = new QVBoxLayout(&wid);
      layout->addWidget(button);
      wid.show();
      return app.exec();
      }

      @

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gogoi
        wrote on last edited by
        #3

        hello sigrid

        Actually the problem is that as i set width and height the buttons the layout change..the code i have wrriten is...here if i dont use setMinimumWidth and setMinimumHeight than layout is fine,but on use of that the layout changes..can u please suggest me wgy this happen..

        @QPushButton *cellbut[6][7]
        QGridLayout *controlyt=new QGridLayout();
        QWidget *centralWidget=new QWidget();
        for(int i=0;i<6;i++)
        {
        for(int j=0;j<7;j++)
        {
        cellBut[i][j]=new QPushButton();
        cellBut[i][j]->setMinimumWidth(68);
        cellBut[i][j]->setMinimumHeight(60);
        controlsLayout->addWidget(cellBut[i][j],i,j);
        }
        }
        ui->centralWidget->setLayout(vLayout);
        setCentralWidget(ui->centralWidget);

        ui->centralWidget->layout()->setSizeConstraint(QLayout::SetNoConstraint);
        

        @

        1 Reply Last reply
        0

        • Login

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