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. Reduce space(h and v) between icon in QGridlayout

Reduce space(h and v) between icon in QGridlayout

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • D Offline
    D Offline
    Dcqt
    wrote on last edited by
    #1

    Hi
    The below code displays some icons in gridlayout.

    i trying to reduce the horizantal space between the icons , but i could not .

    please give me a hint on what are the function i can use to reduce the space(H and V ) between the icons in a laid out in a gridlayout.

    @QGridLayout controlsLayout = new QGridLayout();
    QGridLayout *controlsLayout2 = new QGridLayout();
    controlsLayout2->setHorizontalSpacing(0);
    QWidget *widg = new QWidget;
    setLayout(controlsLayout);// set to mainWindow
    controlsLayout->addWidget(widg);
    widg ->setLayout(controlsLayout2);

    appWidget[app_no]= new QWidget();
    appWidget[app_no]->setFixedSize(78, 78);

              q_Icon[app_no]=new QPushButton();
              q_Icon[app_no]->setFlat(TRUE);
              q_Icon[app_no]->setFixedSize(60,50);
              QPixmap pixmap(somepath);
              QIcon ButtonIcon(pixmap);
              q_Icon[app_no]->setIcon(ButtonIcon);
             label[app_no]= new QLabel(this, 0);
             label[app_no]->setMaximumSize(73,20);
             label[app_no]->setAlignment(Qt::AlignTop|Qt::AlignCenter);
             label[app_no]->setFont(font);
             label[app_no]->setText("<font color = 'white'>"+QString(label_text_list[0]));
             label[app_no]->setFrameStyle(QFrame::NoFrame);
             label[app_no]->setAttribute(Qt::WA_TranslucentBackground, true);
    
            appLayout[app_no] = new QVBoxLayout();
            appLayout[app_no]->addWidget(q_Icon[app_no]);
            appLayout[app_no]->setSpacing(0);
            appLayout[app_no]->addWidget(label[app_no]);
            appLayout[app_no]->sizeConstraint();
            appWidget[app_no]->setLayout(appLayout[app_no]);
            controlsLayout2->addWidget(appWidget[app_no], row_n, col_n, 10, 2, Qt::AlignTop|Qt::AlignLeft);@
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      in your code you mix Layout and setFixedSize() method. Why?

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dcqt
        wrote on last edited by
        #3

        Hi,

        I want the size of button to be remain constant .
        is it a wrong way to do, i really dont know much of Qt?
        i just used by following some examples and some manuals on net.

        my problem is , when the mainwindow is minimized the distance between icons is less, but when it is maximized the distance also increasing.

        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