我实现了一个颜色选择器菜单,基于BlackDal ColorPicker
In order to send a signal, when a color has been selected, i added:
class RColorPicker : public QPushButton
{
Q_OBJECT
signals:
void selected( QColor color);
...
和
void RColorPicker::on_popup_selected( QColor color )
{
_selectedColor = color;
repaint();
emit selected( color );
Sowe在其他地方我连接到那个信号,比如
fillColorButton = new RColorPicker()
connect(fillColorButton , SIGNAL(selected(QColor)), this, SLOT(fillColorButtonTriggered(QColor)) );
这有效,当从 PopUpMenu 中选择一种颜色时,但如果我在 PopUp 中选择“更多...”,然后从被调用的颜色中选择一种颜色,则不会调用QColorDialog
连接的插槽。fillColorButtonTriggered
Instaed,在我的 MDI 应用程序中,一个不同的文档成为活动窗口。虽然它应该:
void RColorPickerPopup::mousePressEvent ( QMouseEvent *event )
{
...
QColorDialog *dialog = new QColorDialog( this );
if( dialog->exec() )
{
hoverColor = dialog->selectedColor();
delete dialog;
emit selected( hoverColor );
this->close();
QColorDialog
如果我用本机 WindowsChooseColor
对话框替换,则不会出现问题。
有没有人有提示,这里有什么问题?