2017-12-09 29 views
0

QPushButtonクラスを使用していて、スタイルシートの設定後にオブジェクトをQGraphicsProxyWidgetに追加しています。ただし、border-radiusと設定すると、background-colorはまだ境界線に重なります。どのように私はこれを取り除くのですか?QPushButton背景色が境界線に重なる

例:(levelOneEasyProxyがあるQGrpahicsProxyWidget

QPushButton* levelOneEasyButton = new QPushButton(); 
levelOneEasyButton->setGeometry(QRect(sceneRect().width()*0.05, sceneRect().height()*0.2, 70, 50)); 
levelOneEasyButton->setText("1"); 
levelOneEasyButton->setStyleSheet("QPushButton {" 
            "background-color: rgb(92, 249, 158);" 
            "color: white;" 
            "font-size: 16px;" 
            "border-style: solid;" 
            "border-width: 2px;" 
            "border-radius: 10px;" 
            "}" 
            "QPushButton:pressed {" 
            "background-color: rgb(66, 191, 118);" 
            "}"); 
levelOneEasyProxy = addWidget(levelOneEasyButton); 
levelOneEasyProxy->setZValue(10.0); 

現在の結果:

enter image description here

答えて

0

は、私は上記のコードを使用してborder-radiusが、背景のニーズを設定することを発見しましたを使用してtranslucentに設定しますQPushButtonの。これは、次のコードで行うことができます。

qPushButtonObject->setAttribute(Qt::WA_TranslucentBackground); 

これは、重複background-colorを取り除くでしょう。

関連する問題