Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. QApplication Stylesheet completely breaks QGraphicsProxyWidget
Forum Update on Monday, May 27th 2025

QApplication Stylesheet completely breaks QGraphicsProxyWidget

Scheduled Pinned Locked Moved Unsolved Qt 6
5 Posts 3 Posters 223 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.
  • P Offline
    P Offline
    Pekoyo
    wrote on 29 Mar 2025, 17:33 last edited by
    #1

    Regardless of the different combination of flags or cache mode in

    GUI::Graphics_Widget::Graphics_Widget(QWidget* widget, QGraphicsItem* parent) :
    	QGraphicsProxyWidget(parent)
    {
    	setWidget(widget);
    	setFlag(QGraphicsItem::ItemIsMovable);
    	setFlag(QGraphicsItem::ItemIsFocusable);
    	setCacheMode(QGraphicsItem::ItemCoordinateCache);
    	setFocusPolicy(Qt::StrongFocus);
    }
    

    As soon as the global stylesheet applied to the application instance has any entry, the widgets inside the Proxy cannot be interacted with anymore, eg (QLineEdit, QComboBox, etc...).

    Example:
    If the stylesheet is "QPushButton { background: red; }", it breaks the proxy / interaction.
    If the stylesheet is "", it works again.

    void GUI::GraphicsView::mousePressEvent(QMouseEvent* event) {
        if (auto item = scene->itemAt(mapToScene(event->pos()), transform())) {
    	if (QGraphicsProxyWidget* proxyWidget = qgraphicsitem_cast<QGraphicsProxyWidget*>(item)) {
                // NEITHER
    	    QApplication::sendEvent(proxyWidget->widget(), event);
                // OR
    	    QApplication::sendEvent(proxyWidget, event);
                // WORK (they are being properly called but the QComboBox does not expand)
    	}
        }
        QGraphicsView::mousePressEvent(event);
    }
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 29 Mar 2025, 20:00 last edited by
      #2

      Hi,

      Which version of Qt ?
      On which OS ?
      Can you provide a minimal compilable example that shows this behavior ?

      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
      • P Offline
        P Offline
        Pekoyo
        wrote on 29 Mar 2025, 23:03 last edited by Pekoyo
        #3

        Sorry, of course
        Qt 6.8.3 (6.8.3_msvc2022_64)
        Windows 11

        Basically as long as there is any stylesheet applied it breaks.
        (Commenting out or doing: app->setStyleSheet(""); returns it to the expected behavior.)

        #include <QtWidgets>
        #include <QtCore>
        #include <QtGui>
        
        int main(int argc, char *argv[]) {
        	auto app = new QApplication(argc, argv);
        	app->setStyleSheet("* {}");
        
        	auto view = new QGraphicsView();
        	auto scene = new QGraphicsScene(view);
        	view->setScene(scene);
        	view->showMaximized();
        
        	auto proxy = new QGraphicsProxyWidget();
        	auto combo = new QComboBox();
        	combo->addItems({ "A", "B", "C" });
        	proxy->setWidget(combo);
        
        	scene->addItem(proxy);
        
        	return app->exec();
        }
        
        1 Reply Last reply
        2
        • A Offline
          A Offline
          Axel Spoerl
          Moderators
          wrote on 30 Mar 2025, 07:49 last edited by
          #4

          Thanks for the comprehensive report.
          You have found a bug, unfortunately. I have created a ticket for it: https://bugreports.qt.io/browse/QTBUG-135340.

          Software Engineer
          The Qt Company, Oslo

          1 Reply Last reply
          1
          • P Offline
            P Offline
            Pekoyo
            wrote on 31 Mar 2025, 15:31 last edited by
            #5

            Thank you very much.

            1 Reply Last reply
            0

            1/5

            29 Mar 2025, 17:33

            • Login

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