Results 1 to 9 of 9

Thread: resize buttons inside

  1. #1
    Join Date
    Nov 2006
    Posts
    96

    Default resize buttons inside

    Hi, take a look at the code:

    Qt Code:
    1. class vnosTab : public QTabWidget {
    2. public:
    3. vnosTab();
    4.  
    5. private:
    6. QVBoxLayout *m_pTopLayoutVnos;
    7.  
    8. QPushButton *m_pVnosUvoznihCarinskih;
    9. QPushButton *m_pVnosUvoznihNecarinskih;
    10. QPushButton *m_pVnosIzvoznihCarinskih;
    11. QPushButton *m_pVnosIzvoznihNecarinskih;
    12. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. vnosTab::vnosTab() {
    2. m_pTopLayoutVnos = new QVBoxLayout;
    3. Q_CHECK_PTR(m_pTopLayoutVnos);
    4.  
    5. //buttons in tab "Vnos"
    6. m_pVnosUvoznihCarinskih = new QPushButton(trUtf8("uvoznih carinskih pošiljk"));
    7. Q_CHECK_PTR(m_pVnosUvoznihCarinskih);
    8. m_pVnosUvoznihNecarinskih = new QPushButton(trUtf8("uvoznih necarinskih pošiljk"));
    9. Q_CHECK_PTR(m_pVnosUvoznihNecarinskih);
    10. m_pVnosIzvoznihCarinskih = new QPushButton(trUtf8("izvoznih carinskih pošiljk"));
    11. Q_CHECK_PTR(m_pVnosIzvoznihCarinskih);
    12. m_pVnosIzvoznihNecarinskih = new QPushButton(trUtf8("izvoznih necarinskih pošiljk"));
    13. Q_CHECK_PTR(m_pVnosIzvoznihNecarinskih);
    14.  
    15. m_pTopLayoutVnos->addWidget(m_pVnosUvoznihCarinskih);
    16. m_pTopLayoutVnos->addWidget(m_pVnosUvoznihNecarinskih);
    17. m_pTopLayoutVnos->addWidget(m_pVnosIzvoznihCarinskih);
    18. m_pTopLayoutVnos->addWidget(m_pVnosIzvoznihNecarinskih);
    19.  
    20. this->setLayout(m_pTopLayoutVnos);
    21. }
    To copy to clipboard, switch view to plain text mode 


    here I'm using the previously declared class
    Qt Code:
    1. void qKobilica::addToolMenu() {
    2. setWindowTitle("Kobilica:");
    3. m_pTopLayout = new QVBoxLayout();
    4. m_pToolbox = new QToolBox;
    5.  
    6. m_pTabSifrant = new QTabWidget;
    7. m_pTabVnos = new vnosTab();
    8. //m_pTabVnos->setHorizontalPolicy(QSizePolicy::Maximum);
    9. m_pTabNatisni = new QTabWidget;
    10.  
    11. //tabs
    12. m_pToolbox->addItem(m_pTabSifrant,trUtf8("Šifranti"));
    13. m_pToolbox->addItem(m_pTabVnos,trUtf8("Vnos"));
    14. m_pToolbox->addItem(m_pTabNatisni,trUtf8("Tiskanje"));
    15. m_pTopLayout->addWidget(m_pToolbox);
    16. //add the central menu to the application
    17. setCentralWidget(m_pToolbox);
    18.  
    19. }
    To copy to clipboard, switch view to plain text mode 
    What I want to do is to resize the buttons (there are 4 at the moment) that would fill the whole canvas (now there's some space in between those buttons), I want only buttons to be on the screen.

  2. #2
    Join Date
    May 2007
    Posts
    91
    Thanks
    60
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: resize buttons inside

    probably this is what you are looking for:
    void QBoxLayout::setSpacing ( int spacing )

  3. #3
    Join Date
    Nov 2006
    Posts
    96

    Default Re: resize buttons inside

    This is not what I'm looking for.

    I want to set size of buttons according to QToolBox's size.

  4. #4
    Join Date
    May 2007
    Posts
    91
    Thanks
    60
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: resize buttons inside

    then what do you mean by "there's some space in between those buttons" ?

    A captured pic may describe your peoblem more easily

  5. #5
    Join Date
    Nov 2006
    Posts
    96

    Default Re: resize buttons inside

    Here:

    http://shrani.si/f/1I/Ll/35PBS70r/snapshot24.png

    You see those buttons not using all the space?

  6. #6
    Join Date
    Nov 2006
    Posts
    96

    Default Re: resize buttons inside

    Does anybody know?

  7. #7
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: resize buttons inside

    Try setting this sizepolicy for all the buttons
    Qt Code:
    1. button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    To copy to clipboard, switch view to plain text mode 
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  8. #8
    Join Date
    Nov 2006
    Posts
    96

    Default Re: resize buttons inside

    You're the man, it works. Thank you

  9. #9
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: resize buttons inside

    eleanor, but that widget is way to big!!!! Make it smaller!!!!
    Qt 5.3 Opensource & Creator 3.1.2

Similar Threads

  1. postponing resize event
    By Honestmath in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2006, 01:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.