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. How to style widgets inside a scrollArea?
QtWS25 Last Chance

How to style widgets inside a scrollArea?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qscrollareaqwidget
8 Posts 2 Posters 1.7k Views
  • 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.
  • C Offline
    C Offline
    candidaj
    wrote on 13 Jul 2022, 08:06 last edited by candidaj
    #1

    I have a widget with scrollArea in it and other widgets which are inside the scrollArea.My problem is the qss i am using to style the widgets inside the scrollArea, is not applying.

    /qss********/
    MyWidget
    {
    background-color: white;
    }

    QLabel
    {
    border: none;
    background-color: white;
    font-size: 10pt;
    }

    QPushButton
    {
    border-style: none;
    color: white;
    font-size: 12pt;
    }

    QPushButton:pressed
    {
    border-style: none;
    color: black;
    }

    QLineEdit
    {
    color: black;
    font-size: 14pt;
    }

    QComboBox
    {
    border-style: solid;
    border-width: 2px;
    border-radius: 3px;
    font-size: 14pt;
    min-height: 38px;
    }

    QComboBox:!editable, QComboBox::drop-down:editable
    {
    background: white;
    border-style: solid;
    border-width: 2px;
    border-radius: 3px;
    }

    QComboBox::drop-down
    {
    subcontrol-origin: padding;
    width: 25px;

     border-left-width: 1px;
     border-left-style: solid; 
     border-top-right-radius: 3px; 
     border-bottom-right-radius: 3px;
    

    }

    QComboBox QAbstractItemView
    {
    border: 2px solid lightgray;
    selection-background-color: lightgray;
    }

    QComboBox QAbstractItemView::item
    {
    min-height: 80px;
    }
    QScrollArea#scrollArea
    {
    background: white;
    border-style: none;
    }

    QWidget#scrollAreaWidgetContents
    {
    background: white;
    border-style: none;
    }

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 Jul 2022, 18:39 last edited by
      #2

      Hi and welcome to devnet,

      Please show the code you use to setup your QScrollArea, the widgets in it and the style sheet.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply 14 Jul 2022, 05:19
      0
      • S SGaist
        13 Jul 2022, 18:39

        Hi and welcome to devnet,

        Please show the code you use to setup your QScrollArea, the widgets in it and the style sheet.

        C Offline
        C Offline
        candidaj
        wrote on 14 Jul 2022, 05:19 last edited by
        #3

        @SGaist This is how i am setting up qscrollarea.
        I have used qt designer to create the widget.
        The QSS is applying to widgets outside the scrollarea, but not to widgets inside scrollarea.

        //Set up Scroll Area
        ui->scrollArea->verticalScrollBar()->setVisible(false);
        ui->scrollArea->horizontalScrollBar()->setVisible(false);
        ui->scrollArea->horizontalScrollBar()->setEnabled(false);
        ui->scrollArea->setWidgetResizable(false);
        ui->scrollAreaWidgetContents->setGeometry(0,0,ui->scroll_Area->width(),1000);
        this->setStyleSheet(fetchQss(staticMetaObject.className()));

        Below is the QSS used to style the widgets inside and outside scrollArea.

        CustomWidget
        {
        background-color: white;
        }

        QCheckBox::indicator
        {
        border: none;
        width: 101px;
        height: 51px;
        }

        QComboBox
        {
        border-style: solid;
        border-width: 2px;
        border-color: #99B359;
        border-radius: 3px;
        font-size: 14pt;
        min-height: 40px;
        }

        QComboBox:!editable, QComboBox::drop-down:editable
        {
        background: white;
        border-style: solid;
        border-width: 2px;
        border-color: #99B359;
        border-radius: 3px;
        }

        QComboBox::drop-down
        {
        subcontrol-origin: padding;
        subcontrol-position: top right;
        width: 25px;

         border-left-width: 1px;
         border-left-color: #99B359;
         border-left-style: solid; 
         border-top-right-radius: 3px; 
         border-bottom-right-radius: 3px;
        

        }

        QComboBox::down-arrow
        {
        image: url(:/drop.png);
        }

        QComboBox QAbstractItemView
        {
        border: 2px solid white;
        selection-background-color: white;
        font-size: 14pt;
        }

        QComboBox QAbstractItemView::item
        {
        min-height: 70px;
        }

        QScrollBar:vertical
        {
        width: 25px;
        }
        QScrollBar::handle:vertical
        {
        background: #E3E3E3; min-height: 25px;
        }

        QPushButton
        {
        border-style: none;
        color: white;
        font-size: 14pt;

        }

        QPushButton:pressed
        {
        border-style: none;
        color: black;
        font-size: 14pt;

        }

        QPushButton:disabled
        {
        border-style: none;
        color: white;
        font-size: 14pt;

        }

        QLineEdit
        {
        border-style: solid;
        border-width: 2px;
        border-color: #99B359;
        border-radius: 3px;
        font-size: 12pt;
        color: black;
        }

        QPushButton#pushButton_ScrollUp
        {
        border-style: none;

        }

        QPushButton#pushButton_ScrollDown
        {
        border-style: none;
        }
        QPushButton#pushButton_ScrollUp:pressed
        {
        border-style: none;

        }

        QPushButton#pushButton_ScrollDown:pressed
        {
        border-style: none;

        }

        QPushButton#pushButton_ScrollDown:disabled
        {
        border-style: none;

        }

        QPushButton#pushButton_ScrollUp:disabled
        {
        border-style: none;

        }

        QLabel#label_Label1
        {
        border: none;
        background-color: white;
        color: #99B359;
        font-size: 24pt;
        }

        QLabel#label_Label2
        {
        border: none;
        background-color: white;
        color: #99B359;
        font-size: 24pt;
        }

        QLabel#label_Label3
        {
        border: none;
        background-color: white;
        color: #99B359;
        font-size: 24pt;
        }

        QLabel#label_Label4
        {
        border: none;
        background-color: white;
        color: #99B359;
        font-size: 24pt;
        }

        QLabel#label_Label5
        {
        border: none;
        background-color: white;
        color: #99B359;
        font-size: 24pt;
        }

        QLabel#label_Label6
        {
        border: none;
        background-color: white;
        color: #99B359;
        font-size: 24pt;
        }

        QLabel#label_Label7
        {
        border: none;
        background-color: white;
        color: #99B359;
        font-size: 24pt;
        }

        QLabel#label_Label8
        {
        border: none;
        background-color: white;
        color: #99B359;
        font-size: 24pt;
        }

        QLabel#Label9
        {
        border: none;
        background-color: white;
        color: #99B359;
        font-size: 24pt;
        }

        QLabel#label_10
        {
        border: none;
        background-color: white;
        color: black;
        font-size: 16pt;
        }

        QScrollArea#scroll_Area
        {
        background: white;
        border-style: none;
        }

        QWidget#scrollAreaWidgetContents
        {
        background: white;
        border-style: none;
        }

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 14 Jul 2022, 19:09 last edited by
          #4

          Did you call that before or after ui->setupUi(this); ?

          By the way, please use coding tags (the </> button) to make your code readable.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          C 1 Reply Last reply 15 Jul 2022, 13:40
          0
          • S SGaist
            14 Jul 2022, 19:09

            Did you call that before or after ui->setupUi(this); ?

            By the way, please use coding tags (the </> button) to make your code readable.

            C Offline
            C Offline
            candidaj
            wrote on 15 Jul 2022, 13:40 last edited by
            #5

            @SGaist I called that after ui->setupUi(this);.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 15 Jul 2022, 19:28 last edited by
              #6

              One thing you can do is test your stylesheet directly in Designer to see if there's something wrong with it.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              C 1 Reply Last reply 22 Jul 2022, 05:27
              0
              • S SGaist
                15 Jul 2022, 19:28

                One thing you can do is test your stylesheet directly in Designer to see if there's something wrong with it.

                C Offline
                C Offline
                candidaj
                wrote on 22 Jul 2022, 05:27 last edited by
                #7

                @SGaist I tested the stylesheet directly in Designer and it is working.
                But why it is not working from code.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 22 Jul 2022, 21:32 last edited by
                  #8

                  Check the generated code to see what it does differently than yours.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  8/8

                  22 Jul 2022, 21:32

                  • Login

                  • Login or register to search.
                  8 out of 8
                  • First post
                    8/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved