我在我的项目中使用libZip,我成功创建了 zip 文件输出,但我很难为 zip 文件设置密码。
我正在调用zip_set_default_password函数,并且得到了 OK 响应,但是当我尝试提取它时,它并没有要求输入密码。
代码示例:
int CompressWithPassword(const char * psFileContent, int iFileSize, const char * pcPassword)
{
zip_source *psZipSource = NULL;
zip_int64_t iIndex = 0;
int iError = EOK;
const char * pcZipOutputPath = "/home/user/Documents/myzip.zip";
// Open zip file.
m_psZip =
zip_open(pcZipOutputPath,
ZIP_CREATE /*Create the archive if it does not exist*/,
&iError);
// Zip opend ?
if(iError != ZIP_ER_OK)
{
Close();
return iError;
}
// Generate zip source content.
psZipSource =
zip_source_buffer(m_psZip, …Run Code Online (Sandbox Code Playgroud) 我试图只改变QCheckBox指示矩形的颜色.
目前我成功绘制了矩形的右边和底线.可能我在这里做错了.
这是我的代码:
CheckBoxWidget.cpp
CheckBoxWidget::CheckBoxWidget(QObject *poParent)
: QItemDelegate(poParent)
{
}
void CheckBoxWidget::drawCheck( QPainter *painter,
const QStyleOptionViewItem &option,
const QRect & rect,
Qt::CheckState state) const
{
QRect oCheckBoxRect =
QApplication::style()->subElementRect( QStyle::SE_CheckBoxIndicator, &option);
painter->setPen(Qt::white);
painter->drawRect(oCheckBoxRect);
QItemDelegate::drawCheck(painter, option, oCheckBoxRect, state);
}
Run Code Online (Sandbox Code Playgroud)
CheckBoxWidget.h
class CheckBoxWidget : public QItemDelegate
{
Q_OBJECT
public:
CheckBoxWidget(QObject *poParent = 0);
virtual ~CheckBoxWidget();
protected:
virtual void drawCheck( QPainter *painter,
const QStyleOptionViewItem &option,
const QRect &,
Qt::CheckState state) const;
};
Run Code Online (Sandbox Code Playgroud)
有什么建议 ?