Could not parse stylesheet of widget

来源:互联网 发布:js验证密码的正则 编辑:程序博客网 时间:2024/04/29 01:13

         今天想调试程序的时候一点窗口就弹出来一堆 Could not parse stylesheet of widget  ,经过检查,不是QSS文件里的问题,也不是designer界面里样式表的问题,肯定是代码里 setStyleSheet 里出错了。果然如此。检查后发现是

ui.pushButtonVideo_1_1->setStyleSheet("border-style: inset; border-width: 4px;   border-radius: 0px; border-color: yellow; color:rgba(0, 0, 0, 100); ");

双引号里面多了个  右花括号 } 去掉就OK啦!


       在 designer 里写 stylesheet 会直接提示是否为有效样式表,我QSS文件里的样式表也是从designer 里拷进去的,这也印证了我的猜测。网上这哥们也遇到过这个问题。




如题

   Could not parse stylesheet of widget 0x10f5a40
   Could not parse stylesheet of widget 0xcecf50
   Could not parse stylesheet of widget 0x10b19b8
   Could not parse stylesheet of widget 0x12444c0
   Could not parse stylesheet of widget 0x114e320
   Could not parse stylesheet of widget 0x1150158
代码:
   this->setStyleSheet("font: 9pt;\nborder: 1px;\nborder-image:url(" + upGraph +");");
   this->setStyleSheet("font: "+size+"pt;\nborder: 1px;\nborder-image:url(" + dnGraph  +");\ncolor:"+forcolor+"}");
【this指的是QPushButton】

可是我程序是正常运行的 样式什么的也没什么问题 但调试就出现上面的提示错误 是怎么回事....


   我找到啦 卜是换行符的原因 this->setStyleSheet("font: "+size+"pt;\nborder: 1px;\nborder-image:url(" + dnGraph +");\ncolor:"+forcolor+"}"); 这个里面size 、dnGraph、forcolor这三个变量 在为空的时候 就会出现Could not parse stylesheet of widget 这种情况  【QString aa=tr("font:%1pt;border: 1px;color:%2;border-image:url(%3);").arg(size).arg(forcolor).arg(dnGraph);
this->setStyleSheet(aa);】我这样写就卜会有那样的错误啦 呵呵..  问题解决啦 

0 0