更新代码
This commit is contained in:
@@ -136,7 +136,7 @@ IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject
|
||||
if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) {
|
||||
int fontId = fontDb.addApplicationFont(fontFile);
|
||||
QStringList listName = fontDb.applicationFontFamilies(fontId);
|
||||
if (listName.count() == 0) {
|
||||
if (listName.size() == 0) {
|
||||
qDebug() << QString("load %1 error").arg(fontName);
|
||||
}
|
||||
}
|
||||
@@ -265,8 +265,8 @@ void IconHelper::setStyle1(QWidget *widget, QList<QToolButton *> btns, QList<int
|
||||
|
||||
void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor)
|
||||
{
|
||||
int btnCount = btns.count();
|
||||
int iconCount = icons.count();
|
||||
int btnCount = btns.size();
|
||||
int iconCount = icons.size();
|
||||
if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) {
|
||||
return;
|
||||
}
|
||||
@@ -329,7 +329,7 @@ void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList
|
||||
|
||||
//可能会重复调用设置所以先要移除上一次的
|
||||
for (int i = 0; i < btnCount; ++i) {
|
||||
for (int j = 0; j < this->btns.count(); j++) {
|
||||
for (int j = 0; j < this->btns.size(); j++) {
|
||||
if (this->btns.at(j) == btns.at(i)) {
|
||||
disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
|
||||
this->btns.at(j)->removeEventFilter(this);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -136,7 +136,7 @@ IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject
|
||||
if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) {
|
||||
int fontId = fontDb.addApplicationFont(fontFile);
|
||||
QStringList listName = fontDb.applicationFontFamilies(fontId);
|
||||
if (listName.count() == 0) {
|
||||
if (listName.size() == 0) {
|
||||
qDebug() << QString("load %1 error").arg(fontName);
|
||||
}
|
||||
}
|
||||
@@ -265,8 +265,8 @@ void IconHelper::setStyle1(QWidget *widget, QList<QToolButton *> btns, QList<int
|
||||
|
||||
void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor)
|
||||
{
|
||||
int btnCount = btns.count();
|
||||
int iconCount = icons.count();
|
||||
int btnCount = btns.size();
|
||||
int iconCount = icons.size();
|
||||
if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) {
|
||||
return;
|
||||
}
|
||||
@@ -329,7 +329,7 @@ void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList
|
||||
|
||||
//可能会重复调用设置所以先要移除上一次的
|
||||
for (int i = 0; i < btnCount; ++i) {
|
||||
for (int j = 0; j < this->btns.count(); j++) {
|
||||
for (int j = 0; j < this->btns.size(); j++) {
|
||||
if (this->btns.at(j) == btns.at(i)) {
|
||||
disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
|
||||
this->btns.at(j)->removeEventFilter(this);
|
||||
|
||||
@@ -30,6 +30,9 @@ PanelWidget::PanelWidget(QWidget *parent) : QWidget(parent)
|
||||
scrollArea->setWidget(scrollAreaContents);
|
||||
frame->setStyleSheet("QFrame#frameMain{border-width:0px;}");
|
||||
|
||||
hSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
vSpacer = new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
|
||||
margin = 0;
|
||||
space = 0;
|
||||
autoWidth = false;
|
||||
@@ -133,12 +136,16 @@ void PanelWidget::loadWidgets()
|
||||
int column = 0;
|
||||
int index = 0;
|
||||
|
||||
//先把之前的所有移除并不可见
|
||||
//先把之前的所有移除并不可见
|
||||
foreach (QWidget *widget, widgets) {
|
||||
gridLayout->removeWidget(widget);
|
||||
widget->setVisible(false);
|
||||
}
|
||||
|
||||
//移除所有弹簧
|
||||
gridLayout->removeItem(hSpacer);
|
||||
gridLayout->removeItem(vSpacer);
|
||||
|
||||
//重新添加到布局中并可见
|
||||
foreach (QWidget *widget, widgets) {
|
||||
gridLayout->addWidget(widget, row, column);
|
||||
@@ -156,13 +163,11 @@ void PanelWidget::loadWidgets()
|
||||
|
||||
//设置右边弹簧
|
||||
if (!autoWidth) {
|
||||
QSpacerItem *hSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
gridLayout->addItem(hSpacer, 0, gridLayout->columnCount());
|
||||
}
|
||||
|
||||
//设置底边弹簧
|
||||
if (!autoHeight) {
|
||||
QSpacerItem *vSpacer = new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
gridLayout->addItem(vSpacer, row, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ class QScrollArea;
|
||||
class QFrame;
|
||||
class QVBoxLayout;
|
||||
class QGridLayout;
|
||||
class QSpacerItem;
|
||||
|
||||
#ifdef quc
|
||||
class Q_DECL_EXPORT PanelWidget : public QWidget
|
||||
@@ -43,6 +44,8 @@ private:
|
||||
QFrame *frame; //放置设备的框架,自动变宽变高
|
||||
QVBoxLayout *verticalLayout; //设备面板总布局
|
||||
QGridLayout *gridLayout; //设备表格布局
|
||||
QSpacerItem *hSpacer; //横向弹簧
|
||||
QSpacerItem *vSpacer; //垂直弹簧
|
||||
|
||||
int margin; //边距
|
||||
int space; //设备之间的间隔
|
||||
|
||||
Reference in New Issue
Block a user