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. QPushButton positioning to the top right corner and to the bottom right corner.

QPushButton positioning to the top right corner and to the bottom right corner.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 405 Views 2 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.
  • E Offline
    E Offline
    ekato993
    wrote on last edited by
    #1

    The following code postion the btn to the top right corner:

    window is a QWidget

    btn1 = new QPushButton(window);
    btnHistory->setFixedSize(10,10);
    
    auto* layout = new QGridLayout(window);
    layout->setContentsMargins(0,0,0,0);
    layout->setMargin(0);
    layout->setSpacing(0);
    layout->addWidget(btn1, 0, 1);
    layout->setRowStretch(1, 1);
    layout->setColumnStretch(0, 1);
    

    I would like to position the the next btn to the bottom right corner, but I do not know how could I reach that.

    btn2 = new QPushButton(window);
    btnHistory->setFixedSize(10,10);
    
    Pl45m4P 1 Reply Last reply
    0
    • E ekato993

      The following code postion the btn to the top right corner:

      window is a QWidget

      btn1 = new QPushButton(window);
      btnHistory->setFixedSize(10,10);
      
      auto* layout = new QGridLayout(window);
      layout->setContentsMargins(0,0,0,0);
      layout->setMargin(0);
      layout->setSpacing(0);
      layout->addWidget(btn1, 0, 1);
      layout->setRowStretch(1, 1);
      layout->setColumnStretch(0, 1);
      

      I would like to position the the next btn to the bottom right corner, but I do not know how could I reach that.

      btn2 = new QPushButton(window);
      btnHistory->setFixedSize(10,10);
      
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @ekato993 said in QPushButton positioning to the top right corner and to the bottom right corner.:

      I would like to position the the next btn to the bottom right corner, but I do not know how could I reach that.

      layout->addWidget(btn1, 0, 1);

      Your first button is in row 0, column 1, which is top right (assuming you have a 2x2 grid).
      Where is the difficulty in changing the the numbers here?

      https://doc.qt.io/qt-5/qgridlayout.html#addWidget-1


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      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