① qtableview的单元格怎么放一个button
#ifndef BUTTONDELEGATE_H
#define BUTTONDELEGATE_H
#include <QItemDelegate>
class ButtonDelegate : public QItemDelegate
{
Q_OBJECT
public:
explicit ButtonDelegate(QObject *parent = 0);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index);
signals:
public slots:
private:
QMap<QModelIndex, QStyleOptionButton*> m_btns;
};
#endif // BUTTONDELEGATE_H
#include "buttondelegate.h"
#include <QApplication>
#include <QMouseEvent>
#include <QDialog>
#include <QPainter>
#include <QStyleOption>
#include <QDesktopWidget>
ButtonDelegate::ButtonDelegate(QObject *parent) :
QItemDelegate(parent)
{
}
void ButtonDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionButton* button = m_btns.value(index);
if (!button) {
button = new QStyleOptionButton();
button->rect = option.rect.adjusted(4, 4, -4, -4);
button->text = "X";
button->state |= QStyle::State_Enabled;
(const_cast<ButtonDelegate *>(this))->m_btns.insert(index, button);
}
painter->save();
if (option.state & QStyle::State_Selected) {
painter->fillRect(option.rect, option.palette.highlight());
}
painter->restore();
QApplication::style()->drawControl(QStyle::CE_PushButton, button, painter);
}
bool ButtonDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
{
if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent* e =(QMouseEvent*)event;
if (option.rect.adjusted(4, 4, -4, -4).contains(e->x(), e->y()) && m_btns.contains(index)) {
m_btns.value(index)->state |= QStyle::State_Sunken;
}
}
if (event->type() == QEvent::MouseButtonRelease) {
QMouseEvent* e =(QMouseEvent*)event;
if (option.rect.adjusted(4, 4, -4, -4).contains(e->x(), e->y()) && m_btns.contains(index)) {
m_btns.value(index)->state &= (~QStyle::State_Sunken);
QDialog *d = new QDialog();
d->setGeometry(0, 0, 200, 200);
d->move(QApplication::desktop()->screenGeometry().center() - d->rect().center());
d->show();
}
}
}
② QStyle *style = widget widget->style() : QApplication::style();谁能解释下这句话是是啥意思啊,QT
widget如果为null,则执行style=QApplication::style(),否则前面那个
③ qstyle女装淘宝上有吗
直接到淘宝搜索一下就知道了呀
④ CAD如何不用再弹出 “指定字体给样式IDQSTYLE”窗口,除了更改CAD的acad.fmp文件之外呢
下载名为hzfs1.shx的字体文件,保存至AutoCAD安装文件夹里名为Fonts的文件夹就可以彻底解决问题。
⑤ oppo ulike style u529现在成都买好多钱这款手机的功能有哪些觉得这款手机咋样
屏幕好,像素高,其他的 也没什么啦,够普通用户使用的,但是上网的话不是很顺畅,因为喜欢是非智能的。。
⑥ qstyleoption.h 什么情况下调用
get和post是请求方式。一般get携带的信息量有限制,而且他的内容会在显示栏里面出现,不安全。post可携带大量数据,并且信息不回出现在显示栏里比较安全。当实现查询功能时适合用get。get效率比post高些。