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. QComboBox FramelessWindowHint not work on MacOS
Forum Updated to NodeBB v4.3 + New Features

QComboBox FramelessWindowHint not work on MacOS

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 321 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.
  • H Offline
    H Offline
    Hector_J
    wrote on last edited by
    #1

    Hello,
    I built a QT application on macOS Big Sur, and my QT version is 6.2.0.
    When I built a custom QComboBox, the drop-list always had a shadow black frame behind it.
    I tried to set flags below, but it still not work on Mac system. (But it works on Windows system)

    comboBox->view()->window()->setWindowFlags( Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
    comboBox->view()->window()->setAttribute(Qt::WA_TranslucentBackground);
    

    f

    detail code:

        comboBox->setStyleSheet("QComboBox {"
                                    "combobox-popup: 0;"
                                    "background: transparent;"
                                    "border:2px solid red;"
                                    "border-radius: 10px;"
                                    "padding-left: 5px;"
                                    "background-color: white;"
                                    "font: bold;"
                                    "font-size: 16px;"
                                    "color: rgb(107,107,107);}"
                                "QComboBox::down-arrow{"
                                    "image: url(:/resources/icons-chevron-text-down.png);"
                                    "background-color: white;}"
                                "QComboBox::drop-down{"
                                    "border:none;"
                                    "subcontrol-position: top right;"
                                    "subcontrol-origin: padding;"
                                    "width:40px;}"
                                "QScrollBar:vertical {"
                                    "border: 1px transparent rgb(213, 218, 223);"
                                    "background:rgb(213, 218, 223);"
                                    "border-radius: 2px;"
                                    "width:6px;"
                                    "margin: 2px 0px 2px 1px;}"
                                "QScrollBar::handle:vertical {"
                                    "border-radius: 2px;"
                                    "min-height: 0px;"
                                    "background-color: rgb(131, 131, 131);}"
                                "QScrollBar::add-line:vertical {"
                                    "height: 0px;"
                                    "subcontrol-position: bottom;"
                                    "subcontrol-origin: margin;}"
                                "QScrollBar::sub-line:vertical {"
                                    "height: 0px;"
                                    "subcontrol-position: top;"
                                    "subcontrol-origin: margin;}");
    
        QListView *view = new QListView(comboBox);
        view->setStyleSheet("QListView{top: 2px;"
                                "border:1px solid red;"
                                "border-radius: 8px;"
                                "background-color: white;"
                                "show-decoration-selected: 1;"
                                "padding-left: 5px;"
                                "padding-right: 6px;"
                                "padding-top: 6px;"
                                "padding-bottom: 2px;"
                                "font: bold;"
                                "font-size: 16px;}"
                            "QListView::item{"
                                "height: 30px;"
                                "background-color: white;"
                                "color: rgb(107,107,107);}"
                            "QListView::item:hover{"
                                "background-color: green;"
                                "color: white;}");
        view->setCursor(Qt::PointingHandCursor);
        comboBox->setView(view);
        comboBox->setMaxVisibleItems(5);
        comboBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
        comboBox->setFixedSize(500,45);
        comboBox->view()->window()->setWindowFlags( Qt::Popup | Qt::FramelessWindowHint |Qt::NoDropShadowWindowHint);
        comboBox->view()->window()->setAttribute(Qt::WA_TranslucentBackground);
    
    1 Reply Last reply
    0

    • Login

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