Skip to content

QAbstractScrollArea without frame #353

@hmaarrfk

Description

@hmaarrfk

Describe Your Environment

Linux + PySide6

Please, report the output of the command (from v2.6+) or fill the information below:

$ qdarkstyle --all

Or use the helpdev if you have

$ helpdev

[Versions from your environment]

  • QDarkStyle: main
  • OS: Linux
  • Python: 3.10

[If used, please inform their versions]

  • PySide: 6.7.0

Language

Python

Description / Steps to Reproduce [if necessary]

It is difficult to have a QScrollArea without a border

Sample code
import sys
from PySide6.QtWidgets import QApplication, QMainWindow, QSplitter, QScrollArea, QWidget, QPushButton, QVBoxLayout, QFrame
from PySide6.QtCore import Qt

import qdarkstyle

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        splitter = QSplitter(Qt.Horizontal)

        # Left side scroll area with frame
        left_scroll_area = QScrollArea()
        left_widget = QWidget()
        left_layout = QVBoxLayout(left_widget)

        for i in range(4):
            btn = QPushButton(f"Button {i + 1}")
            left_layout.addWidget(btn)

        left_scroll_area.setWidget(left_widget)
        left_scroll_area.setWidgetResizable(True)
        left_scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        left_scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)

        # Right side scroll area without frame
        right_scroll_area = QScrollArea()
        right_scroll_area.setFrameShape(QFrame.NoFrame)
        right_widget = QWidget()
        right_layout = QVBoxLayout(right_widget)

        for i in range(4):
            btn = QPushButton(f"Button {i + 1}")
            right_layout.addWidget(btn)

        right_scroll_area.setWidget(right_widget)
        right_scroll_area.setWidgetResizable(True)
        right_scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        right_scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)

        splitter.addWidget(left_scroll_area)
        splitter.addWidget(right_scroll_area)

        self.setCentralWidget(splitter)
        self.setWindowTitle("Split Pane Example")
        self.setGeometry(300, 300, 800, 600)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    stylesheet = qdarkstyle.load_stylesheet()
    app.setStyleSheet(stylesheet)

    window = MainWindow()
    window.show()
    sys.exit(app.exec())

Actual Result

Screenshot from 2024-05-19 22-41-12

Notice the 1 pixel border on both side of the split pane. But I asked for no frame on the right.

Expected Results / Proposed Result

The ability to turn off the frame.

Screenshot from 2024-05-19 22-41-32

Relevant Code [if necessary]

Add the frameShape=0 section??? Taken from QFrame

QAbstractScrollArea {
    background-color: $COLOR_BACKGROUND_1;
    border: $BORDER_2;
    border-radius: $SIZE_BORDER_RADIUS;
    /* fix #159 */
    padding: 2px;
    /* remove min-height to fix #244 */
    color: $COLOR_TEXT_1;

    &:disabled {
        color: $COLOR_DISABLED;
    }

    /* vvvvvvv these 5 lines are new */
    /* No frame */
    &[frameShape="0"] {
        border-radius: $SIZE_BORDER_RADIUS;
        border: 1px transparent $COLOR_BACKGROUND_4;
    }
}

There may be the need to have to other parts of it.

Here is a video of me toggling between the "original" and "fixed" screenshot for drama.

Screencast.from.2024-05-19.22-43-38.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions