Qt按钮如何实现icon,text上下排列显示
MVC模型绘制界面,model与delegate无法关联问题
淡出动画无效怎么办?
QWebview背景透明
目录
QListWidget如何实现流式布局
Qt按钮如何实现icon,text上下排列显示
QListWidget清除时遇到的坑
MVC模型绘制界面,model与delegate无法关联问题
淡出动画无效怎么办?
QListWidget如何实现流式布局
ui->listWidget->setViewMode(QListView::IconMode);
ui->listWidget->setFlow(QListView::LeftToRight);//横向排列
ui->listWidget->setResizeMode(QListView::Adjust);//缩放适应
Qt按钮如何实现icon,text上下排列显示
/*实现按钮文字在图片下面 需要使用toolButton*/
QToolButton* toolBtn = new QToolButton;
toolBtn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);//重要的一句
QListWidget清除时遇到的坑
//清空listwidget时 如果之前connect了信号和槽 一定要 先disconnect
disconnect(listwidget,&QListWidget::signal_xxx,this,&xxx::slot_xxx);
//写完之后去清除就不会遇到崩溃及一些无法追踪的问题
MVC模型绘制界面,model与delegate无法关联问题
//若绘制定义listview中发现委托和模型无法关联的情况下找到自定义model中的rowCount函数,返回自己存储的数据列表的size。
int myModel::rowCount(const QModelIndex &parent) const
{
// For list models only the root node (an invalid parent) should return the list's size. For all
// other (valid) parents, rowCount() should return 0 so that it does not become a tree model.
if (parent.isValid())
return 0;
return m_dataList.size();//自己存储的数据列表
}
淡出动画无效怎么办?
//发现以上方法无法对 pGiftItem 起作用
QPropertyAnimation *animation = new QPropertyAnimation(pGiftItem,“windowOpacity”);
animation->setDuration(500);
animation->setStartValue(1);
animation->setEndValue(0);
//需要给 pGiftItem 重新设置 透明度
QGraphicsOpacityEffect *pOpacity = new QGraphicsOpacityEffect(this);
pOpacity->setOpacity(1);
pGiftItem->setGraphicsEffect(pOpacity);
//再次设置目标对象及属性 就可以使需要动画的控件 达到淡出的效果 当然 淡入也是一样的
QPropertyAnimation *animation = new QPropertyAnimation(pGiftItem);
animation->setTargetObject(pOpacity);
animation->setPropertyName("opacity");
animation->setDuration(500);
animation->setStartValue(1);
animation->setEndValue(0);
QPalette pal = view->page()->palette();
pal.setBrush(QPalette::Base, Qt::transparent);
view->setPalette(pal);
|