0

我正在使用窗口 qt,这是我的代码:

LaserEllipse::LaserEllipse(QWidget *parent):
                .....
        QLabel(parent),
        _colore(new QColorDialog(this))
{
    ......
    _colore->setCurrentColor(....);


    // COSTRUZIONE MENU     
    _action_remove = new QAction("Remove Item" , this );
    _action_color = new QAction("Change color" , this );    

    _contextMenu->addAction(_action_color);
    _contextMenu->addAction(_action_remove);

    connect(_action_remove, SIGNAL(triggered()), this, SLOT(action_remove()));
    connect(_action_color, SIGNAL(triggered()), this, SLOT(action_color()));

    _contextMenu->setStyleSheet("QMenu{background-color: rgba(255,255,255,255);selection-color: black;selection-background-color: rgba(162,217,247);}");
    _colore->setStyleSheet("background-color: rgba(255,255,255,255);");
};



void LaserEllipse::action_color()   
{   
    _colore->open(this, SLOT(aggiornaEllipse()));   
}

void LaserEllipse::aggiornaEllipse()
{
    _ellipse_t->setColor(_colore->currentColor().toRgb().name().toStdString());
    _ellipse_t->setCX(this->geometry().center().x()); 
    _ellipse_t->setCY(this->geometry().center().y()); 
    _ellipse_t->setRX(this->width() / 2);
    _ellipse_t->setRY(this->height() / 2);  
}

在最后一行,在action_color插槽功能中,出现QColorDialog,但如果我点击“确定”按钮按住不工作,如果我点击“取消”没有任何反应。要更改颜色,我必须按 Enter。

怎么了 ?

4

0 回答 0