① 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高些。