Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. In Mac platform, qt widget sometime will display blank,how to deal with it?

In Mac platform, qt widget sometime will display blank,how to deal with it?

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 2 Posters 3.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gavinliu
    wrote on last edited by
    #1

    mac, os x yosemite 10.10.2
    normal display
    blank display
    When my mouse move on the contact list, blank will display.
    To resolve this problem, i add update when receive mouse move event.
    but, in this case, the widget will flash(first blank, second i update it), not a good experience。
    Anyone could give me some advice? Thanks very much.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should post a minimal sample code that reproduces that behavior

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        You should post a minimal sample code that reproduces that behavior

        G Offline
        G Offline
        gavinliu
        wrote on last edited by
        #3

        @SGaist
        Thanks, the same code can run well on window7 platform.
        When on Mac, sometimes it will be blank, most time it run well.
        This is the mouseMoveEvent():

        void CombineListView::mouseMoveEvent(QMouseEvent event)
        {
        QModelIndex index = indexAt(event->pos());
        QRect closeBtnRect = index.data(IM_POS).toRect();
        QStandardItemModel
        p =dynamic_cast<QStandardItemModel*>(this->model()) ;
        QStandardItem* item = p->itemFromIndex(index);
        if(NULL != item)
        {
        if(closeBtnRect.contains(event->pos()))
        {
        item->setData(CLOSEBTN_HOVER,IM_ADDICON);
        item->setToolTip("ClickToClose");
        }
        else
        {
        item->setData(CLOSEBTN_NORMAL,IM_ADDICON);
        item->setToolTip(item->data(IM_NAME).toString());
        }
        }

        QListView::mouseMoveEvent(event);
        

        }

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Are you using a custom delegate ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          G 2 Replies Last reply
          0
          • SGaistS SGaist

            Are you using a custom delegate ?

            G Offline
            G Offline
            gavinliu
            wrote on last edited by
            #5

            @SGaist
            Yes, using a custom delegate.

            1 Reply Last reply
            0
            • SGaistS SGaist

              Are you using a custom delegate ?

              G Offline
              G Offline
              gavinliu
              wrote on last edited by
              #6

              @SGaist
              Thank you ,and there a another question.
              My app's UI always has a blue frame on mac os when it get focus,like this:
              blue frame
              When the username get focus, it has a blue frame.
              I know that is the os's setting in General-Appearance-Blue
              So what should i to do to avoid this ?
              Thanks very much.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Then I'd check the delegate implementation of the paint function for something fishy.

                Please, keep that question on the other thread you opened, otherwise it's going to get messy.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                G 1 Reply Last reply
                0
                • SGaistS SGaist

                  Then I'd check the delegate implementation of the paint function for something fishy.

                  Please, keep that question on the other thread you opened, otherwise it's going to get messy.

                  G Offline
                  G Offline
                  gavinliu
                  wrote on last edited by
                  #8

                  @SGaist
                  The code is transplant from WIN32 platform, and the app runs well on WIN32.
                  The blank happens when move mouse on contact list, where will raise mousemove event.
                  Another case, when other app's frame covers my app for a little time, then move out, my app's frame display blank, unless I click on the blank it will display normal

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Can you share the delegate paint implementation ? Without seeing any code it's pretty much Crystal Ball debugging.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    G 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Can you share the delegate paint implementation ? Without seeing any code it's pretty much Crystal Ball debugging.

                      G Offline
                      G Offline
                      gavinliu
                      wrote on last edited by SGaist
                      #10

                      @SGaist Yes,here it is:

                      void CombineListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
                      {
                          const QStandardItemModel* modelTemp = dynamic_cast<const QStandardItemModel*>(index.model()) ;
                          if (NULL == modelTemp)
                          {
                              LOG_WARNING<<"modelTemp is null"<<LOG_END;
                              return;
                          }
                      
                          QStandardItem* sitem = modelTemp->itemFromIndex(index);
                          if(NULL == sitem)
                          {
                              LOG_WARNING<<"sitem is null"<<LOG_END;
                              return;
                          }
                      
                          bool selected=option.state &QStyle::State_Selected;;
                          QPalette palette(option.palette);
                          palette.setColor(QPalette::Active, QPalette::Window,
                              selected ? option.palette.highlight().color()
                              : option.palette.base().color());
                          palette.setColor(QPalette::Active, QPalette::WindowText,
                              selected
                              ? option.palette.highlightedText().color()
                              : option.palette.text().color());
                      
                           //鼠标悬浮着色
                           if (selected)
                           {
                       		QRect fill_rect(option.rect.x(),option.rect.y(),option.rect.width(),option.rect.height());        
                       		QBrush brush(cSelectColor);
                       		painter->fillRect(fill_rect, brush);
                           }
                           if(option.state&QStyle::State_MouseOver && m_bHover)
                           {
                               if(!selected)
                               {
                       			QRect fill_rect(option.rect.x(),option.rect.y(),option.rect.width(),option.rect.height());
                       			QBrush brush(cHoverColor);
                       			painter->fillRect(fill_rect,brush);
                               }
                       
                               //关闭窗口按钮
                               QPixmap closeBtn;
                               closeBtn.load(sitem->data(IM_ADDICON).toString());
                               QRect closeBtnRect = QRect(option.rect.right() - ADAPT_DPI_INT(3) - ADAPT_DPI_INT(closeBtn.width()),
                                   option.rect.y() + ADAPT_DPI_INT(9),
                                   ADAPT_DPI_INT(closeBtn.width()),
                      			 ADAPT_DPI_INT(closeBtn.height()));
                               painter->drawPixmap(closeBtnRect,closeBtn);
                               sitem->setData(closeBtnRect,IM_POS);
                           }
                       
                           if(sitem->data(IM_ISALERT).toBool())
                           {
                               QBrush   brush(cAlertColor);
                               QRect fill_rect(option.rect.x(),option.rect.y(),option.rect.width(),option.rect.height());
                               painter->fillRect(fill_rect,brush);
                               if(option.state&QStyle::State_MouseOver && m_bHover)
                               {
                                   //关闭窗口按钮
                                   QPixmap closeBtn;
                                   closeBtn.load(sitem->data(IM_ADDICON).toString());
                                   QRect closeBtnRect = QRect(option.rect.right() - ADAPT_DPI_INT(3) - ADAPT_DPI_INT(closeBtn.width()),
                                       option.rect.y() + ADAPT_DPI_INT(9),
                                       ADAPT_DPI_INT(closeBtn.width()),
                                       ADAPT_DPI_INT(closeBtn.height()));
                                   painter->drawPixmap(closeBtnRect,closeBtn);
                                   sitem->setData(closeBtnRect,IM_POS);
                               }
                           }
                      
                          /**************************设置状态图标*********************************/
                          QPixmap statusIcon;
                          QString iconPath;
                      	QString strStatusName;
                      	QList<QPixmap> pixmapStatus;
                      	QPixmap iconfirst;
                      	QPixmap iconSecond;
                      	bool bIsMuc = sitem->data(IM_ISMUC).toBool();
                      	if (!bIsMuc)
                      	{
                      		int iStatus = sitem->data(IM_ONLINESTATUE).toInt();
                      		int iPlatForm = sitem->data(IM_MOBILEPLATFORM).toInt();
                      		strStatusName = CommonFun::getStatusTypeName(iStatus, iPlatForm);
                      
                      		if (sitem->data(IM_ISSYSNOTICE).toBool())
                      		{
                      			strStatusName = QString(QChar(0xe6e9));	// 系统通知的小图标
                      		}
                      	//	pixmapStatus = CommonFun::getStatusIcon(iStatus, iPlatForm);
                      	//	iconfirst = pixmapStatus.first();
                      	//	iconSecond = pixmapStatus.last();
                      	}
                      	
                          /**************************设置名字*********************************/
                      	QFont font;
                      	font.setFamily("微软雅黑");
                      	font.setPixelSize(ADAPT_DPI_INT(12));
                      	painter->setFont(font);
                      	painter->setPen(cFontColor);
                      	QRect nameRect;
                      	if (!bIsMuc)
                      	{
                      		nameRect = QRect(ADAPT_DPI_INT(15), option.rect.y(), option.rect.right()-ADAPT_DPI_INT(66), option.rect.height());
                      	}
                      	else
                      	{
                      		nameRect = QRect(ADAPT_DPI_INT(15), option.rect.y(), option.rect.right()-ADAPT_DPI_INT(22), option.rect.height());
                      	}
                          QString text= QAbstractItemDelegate::elidedText(painter->fontMetrics(),nameRect.width(),Qt::ElideRight,sitem->data(IM_NAME).toString());// + strStatusName;
                          QTextOption textop(Qt::AlignVCenter);
                          painter->drawText(nameRect, text, textop);
                      	int i = nameRect.right();
                      	QFont font_icon(CommonFun::getIconFont());
                      	font_icon.setPixelSize(ADAPT_DPI_INT(14));
                      	painter->setFont(font_icon);
                      	QRect statusRect(nameRect.right()+ADAPT_DPI_INT(18), nameRect.y()+ADAPT_DPI_INT(7),painter->fontMetrics().width(strStatusName), painter->fontMetrics().height() );
                      	painter->drawText(statusRect, strStatusName);
                      // 	QRect statusRectFirst(nameRect.right()+18, nameRect.y()+7,iconfirst.width(), iconfirst.height() );
                      // 	painter->drawPixmap(statusRectFirst, iconfirst);
                      // 	QRect statusRectSecond(nameRect.right(), statusRectFirst.y(),iconSecond.width(), iconfirst.height() );
                      // 	painter->drawPixmap(statusRectSecond, iconSecond);
                      
                      	//拖动排序时的悬浮效果
                      	if(m_bDraging)
                      	{
                      		if (!selected && option.state&QStyle::State_MouseOver)
                      		{
                      			painter->drawRect(option.rect);
                      		}
                      	}
                      }
                      

                      [edit: added missing coding tags SGaist]

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Are you sure that you don't return early when you have that white cell showing ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        G 2 Replies Last reply
                        0
                        • SGaistS SGaist

                          Are you sure that you don't return early when you have that white cell showing ?

                          G Offline
                          G Offline
                          gavinliu
                          wrote on last edited by
                          #12

                          @SGaist I will have a check, thanks.

                          1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Are you sure that you don't return early when you have that white cell showing ?

                            G Offline
                            G Offline
                            gavinliu
                            wrote on last edited by
                            #13

                            @SGaist Thanks again. There is another question.
                            If there has another app covers my widget for a while, after I move the app out, my widget will be blank.The same code runs well on WIN32 platform.
                            Normal widget
                            Blank widget
                            For this situation, if I click on the widget, it will be ok.
                            How could i to do for the blank widget?

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              The files are not available currently

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              G 1 Reply Last reply
                              0
                              • SGaistS SGaist

                                The files are not available currently

                                G Offline
                                G Offline
                                gavinliu
                                wrote on last edited by
                                #15

                                @SGaist Can't open the pictures ?

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  No, error 400

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved