gpt4 book ai didi

c++ - 从 Qt5 ColorDialog 中删除颜色渐变窗口

转载 作者:行者123 更新时间:2023-11-28 06:44:19 24 4
gpt4 key购买 nike

这是来自 Qt5 的标准 Color Dialog

enter image description here

是否可以单独查看基本颜色并从对话框中删除颜色渐变?

最佳答案

我找到了这个问题的简单解决方案。这不是删除,但使用我的代码,我们看不到这个渐变,也无法使用它。

我们需要创建子类。让我们编码:

我的颜色对话框

#ifndef MYCOLORDIALOG_H
#define MYCOLORDIALOG_H

#include <QColorDialog>
#include <QLabel>

class MyColorDialog : public QColorDialog
{
Q_OBJECT
public:
explicit MyColorDialog(QWidget *parent = 0);

signals:

public slots:


};

#endif // MYCOLORDIALOG_H

我的颜色对话框.cpp

#include "mycolordialog.h"

MyColorDialog::MyColorDialog(QWidget *parent) :
QColorDialog(parent)
{
QLabel * l = new QLabel("Teeeeext",this);
l->setGeometry(245,5,325,215);//this values control the area and position of label
//you can change this values and remove another area of main dialog window

QPixmap pixmap("G:/2/qt.jpg");
l->setPixmap(pixmap.scaled(325,215,Qt::IgnoreAspectRatio));;//resize our picture
l->show();
}

如何使用???

#include "mycolordialog.h"
//...
void MainWindow::on_pushButton_16_clicked()
{
MyColorDialog cd;
cd.exec();
qDebug() << cd.selectedColor();
}

您可以在标签中设置应用程序的漂亮 Logo 或其他内容。我使用这里的标志 http://reichertbrothers.com/images/qt-logo.png , 但我把它转换成 jpg 格式。

我们得到了什么???

enter image description here

请注意,所有其他区域都可用,您可以选择任何颜色并根据需要进行工作,但此渐变窗口已删除!!

希望对你有帮助。

关于c++ - 从 Qt5 ColorDialog 中删除颜色渐变窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25302194/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com