Results 1 to 5 of 5

Thread: vertical slider

  1. #1
    Join Date
    Apr 2009
    Posts
    75
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default vertical slider

    Hi

    I'va a simple window (QMainWindow):

    Qt Code:
    1. FormTransportOperacje::FormTransportOperacje(QString ID_transport, QWidget *parent) : QMainWindow(parent)
    2. {
    3. this->setMaximumHeight(400);
    4. QWidget *base = new QWidget();
    5. QGridLayout *layout = new QGridLayout(base);
    6. QSqlQuery query("SELECT Imie, Nazwisko, Data_operacji, Nazwa_operacji FROM m_transporty_operacje AS Top LEFT JOIN m_uzytkownicy AS U ON (U.ID_u=Top.ID_uzytkownik) WHERE ID_transport="+ID_transport+" ORDER BY Data_operacji DESC");
    7.  
    8. int i = 0;
    9. while (query.next()) {
    10. QGroupBox *GbTMP= new QGroupBox(query.value(3).toString());
    11. GbTMP->setMinimumHeight(70);
    12. GbTMP->setMaximumHeight(70);
    13. QGridLayout *layoutTMP = new QGridLayout();
    14. QDateTime DTData = query.value(2).toDateTime();
    15.  
    16. QLabel *Uzytkownik = new QLabel(query.value(0).toString()+" "+query.value(1).toString());
    17. QLabel *Data_operacji = new QLabel(DTData.toString("yyyy-MM-dd HH:mm:ss"));
    18.  
    19. GbTMP->setLayout(layoutTMP);
    20. layout->addWidget(GbTMP,i++,0,1,1);
    21. }
    22.  
    23. base->show();
    24. this->setCentralWidget(base);
    25. this->move(((QApplication::desktop()->width()-this->width())/2),((QApplication::desktop()->height()-this->height())/2));
    26.  
    27. }
    To copy to clipboard, switch view to plain text mode 

    And when there are many records, the window extends beyond the boundary of screen.

    How can I "freez" the size of window, and add the verticalslider when the content does not fit in the window?

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: vertical slider

    use a QScrollArea as your central widget.

  3. #3
    Join Date
    Apr 2009
    Posts
    75
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: vertical slider

    I've used:
    Qt Code:
    1. Sa->setWidgetResizable(true);
    2. Sa->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    3. Sa->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    4. QWidget *base = new QWidget(Sa);
    5.  
    6.  
    7. .
    8. .
    9. .
    10. base->show();
    11. this->setCentralWidget(Sa);
    To copy to clipboard, switch view to plain text mode 

    and Scroll has appeard but ther is no active :/

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: vertical slider

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2009
    Posts
    75
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: vertical slider

    Thanks! It's working.

Similar Threads

  1. linking a slider to a global variable
    By switch in forum Newbie
    Replies: 6
    Last Post: 5th August 2009, 08:02
  2. Replies: 13
    Last Post: 21st May 2009, 07:43
  3. get slider value
    By eric in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2007, 19:47
  4. Tick Labels for Slider
    By jcraig in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2007, 17:21
  5. 4.3: Styling vertical QSlider
    By Angelo Moriconi in forum Qt Programming
    Replies: 4
    Last Post: 18th June 2007, 16:04

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.