stylesheet is not applying in sub-menu
Solved
General and Desktop
-
i applied this stylesheet .it applied fine in menu but sub menu is not showing the stylesheet
QMenu { background-color: @color01; color: @color07; border: 1px solid @color05;} QMenu::item { background-color: transparent;} QMenu::item:selected { background-color: @color04;} QMenu::separator { height: 1px; background: @color05; margin-left: 10px; margin-right: 5px;}
the sub-menu is created by another function
QMenu* corefm::createOpenWithMenu() { QMenu *openMenu = new QMenu(tr("Open with")); // Adding CoreApps openMenu->addAction(ui->actionCoreImage); openMenu->addAction(ui->actionCorePaint); openMenu->addAction(ui->actionCorePad); openMenu->addAction(ui->actionCorePlayer); openMenu->addAction(ui->actionCorePDF); // Select action QAction *selectAppAct = new QAction(tr("Select..."), openMenu); connect(selectAppAct, SIGNAL(triggered()), this, SLOT(selectApp())); // Load default applications for current mime QString mime = mimeUtils->getMimeType(curIndex.filePath()); QStringList appNames = mimeUtils->getDefault(mime); // Create actions for opening QList<QAction*> defaultApps; foreach (QString appName, appNames) { // Skip empty app name if (appName.isEmpty()) { continue; } // Load desktop file for application DesktopFile df = DesktopFile("/usr/share/applications/" + appName); // Create action QAction* action = new QAction(df.getName(), openMenu); action->setData(df.getExec()); action->setIcon(FileUtils::searchAppIcon(df)); defaultApps.append(action); // TODO: icon and connect connect(action, SIGNAL(triggered()), SLOT(openInApp())); // Add action to menu openMenu->addAction(action); } // Add open action to menu openMenu->addSeparator(); openMenu->addAction(selectAppAct); return openMenu; }
-
@saber
if possible, you can try to set the stylesheet globally on the QApplication instance.
This should affect all windows, even those outside the parent-child hierarchy (or make sure that the created sub-menu has the correct parent menu widget set in order to inherit the style) -
i added the stylesheet globally on the QApplication .but not changes.
how can i set the submenu parent ?? -
@saber said in stylesheet is not applying in sub-menu:
i added the stylesheet globally on the QApplication .but not changes.
how exactly? This approach should definitely work
Also whats the type of thecorefm
class?