Results 1 to 2 of 2

Thread: scroll bars in QTabWidget--i don't want them

  1. #1
    Join Date
    Sep 2008
    Location
    Falmouth, MA, USA
    Posts
    34
    Thanks
    4
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default scroll bars in QTabWidget--i don't want them

    I am trying to set up cascading tabs using QTabWidget.

    A tab widget appears inside of another tabwidget, which is itself inside of another tab widget

    the innermost tab widget has a variable number of tabs. It is being sized way too small, and if I put more than 4 tabs on it, scroll buttons appear on it no matter what I do, including using setUsesScrollButtons(false).

    here is the code

    Qt Code:
    1. BusAlarms::BusAlarms(int busNumber)
    2. {
    3. locationLabel = new QLabel("location: " + (QString)hotel.getLaneconBusLocation(busNumber));
    4. busNumberLabel = new QLabel("bus number: " + QString::number(busNumber));
    5.  
    6. laneconTabs = new QTabWidget;
    7.  
    8.  
    9. for(int laneconN = 0; laneconN < hotel.getNOfLanecons(busNumber); laneconN++){
    10.  
    11. laneconAlarms[laneconN] = new LaneconAlarms(laneconN,busNumber);
    12.  
    13. laneconTabs->addTab(laneconAlarms[laneconN],QString::number(hotel.getLaneconID( busNumber, laneconN),16));
    14. }
    15.  
    16. QGridLayout *vLayout = new QGridLayout;
    17. vLayout->addWidget(busNumberLabel,0,0);
    18. vLayout->addWidget(locationLabel,1,0);
    19. vLayout->addWidget(laneconTabs,2,0);
    20.  
    21. laneconTabs->setUsesScrollButtons(false);
    22.  
    23. setLayout(vLayout);
    24. }
    To copy to clipboard, switch view to plain text mode 

    here is where LaneconAlarms is built:

    Qt Code:
    1. LaneconAlarms::LaneconAlarms(int laneconNumber, int busNumber)
    2. {
    3. QGridLayout *vLayout = new QGridLayout;
    4. idLabel = new QLabel("ID: " + QString::number(hotel.getLaneconID( busNumber, laneconNumber),16));
    5. vLayout->addWidget(idLabel,0,0);
    6. for(int switchN = 0; switchN < hotel.getNOfLaneconSwitches(busNumber, laneconNumber); switchN++){
    7. switchLabels[switchN] = new QLabel(QString::number(switchN));
    8. vLayout->addWidget(switchLabels[switchN],1+switchN,0);
    9. }
    10. voltageLabel = new QLabel("voltage: ");
    11. currentLabel = new QLabel("current: ");
    12. gfLabel = new QLabel("gf: ");
    13. voltageAlarmAcknowledge = new QCheckBox("acknowledge");
    14. currentAlarmAcknowledge = new QCheckBox("acknowledge");
    15. gfAlarmAcknowledge = new QCheckBox("acknowledge");
    16.  
    17. vLayout->addWidget(voltageLabel,2+MAX_NUMBER_OF_SWITCHES_PER_LANECON,0);
    18. vLayout->addWidget(currentLabel,3+MAX_NUMBER_OF_SWITCHES_PER_LANECON,0);
    19. vLayout->addWidget(gfLabel,4+MAX_NUMBER_OF_SWITCHES_PER_LANECON,0);
    20.  
    21. vLayout->addWidget(voltageAlarmAcknowledge,2+MAX_NUMBER_OF_SWITCHES_PER_LANECON,1);
    22. vLayout->addWidget(currentAlarmAcknowledge,3+MAX_NUMBER_OF_SWITCHES_PER_LANECON,1);
    23. vLayout->addWidget(gfAlarmAcknowledge,4+MAX_NUMBER_OF_SWITCHES_PER_LANECON,1);
    24. setLayout(vLayout);
    25.  
    26. }
    To copy to clipboard, switch view to plain text mode 

    each LaneconAlarm is fairly small in screen space, and each tab is drawn only to its required size. So instead of a tab widget that fills the available space--or even makes it expand-- I have a small set of tabs with scroll bars, and lots of available space around it. What I would like is for the widgets to expand into that available space.

    I have tried very hard to attach an image that shows the result of my code, but the attachment technique doesn't appear to work--when I either select my image or drag it into the attachment window, I end up with a window showing my image, but no other options for attach, post inline, etc.

    any ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: scroll bars in QTabWidget--i don't want them

    Quote Originally Posted by jhowland View Post
    What I would like is for the widgets to expand into that available space.
    This sounds like you didn't use a layout somewhere.

    I have tried very hard to attach an image that shows the result of my code, but the attachment technique doesn't appear to work--when I either select my image or drag it into the attachment window, I end up with a window showing my image, but no other options for attach, post inline, etc.
    You could use a website like imageshack and post the link here.

Similar Threads

  1. scroll bars are not appearing
    By Cruz in forum Qt Programming
    Replies: 4
    Last Post: 10th September 2010, 18:26
  2. QGraphicsView scroll bars disappears
    By jano_alex_es in forum Qt Programming
    Replies: 4
    Last Post: 25th November 2009, 15:17
  3. Replies: 1
    Last Post: 11th June 2009, 06:49
  4. How to find the presence of scroll bars at run time
    By anju123 in forum Qt Programming
    Replies: 8
    Last Post: 28th July 2007, 21:30
  5. QScrollArea's Scroll Bars
    By ToddAtWSU in forum Qt Programming
    Replies: 5
    Last Post: 19th September 2006, 14:27

Tags for this Thread

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.