Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. 欢迎大家来到Qt中文论坛
Qt 6.11 is out! See what's new in the release blog

欢迎大家来到Qt中文论坛

Scheduled Pinned Locked Moved Chinese
87 Posts 66 Posters 182.7k Views 2 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.
  • T Offline
    T Offline
    the_maskedman
    wrote on last edited by
    #55

    新人来报个到.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hou_jiangzhen
      wrote on last edited by
      #56

      @
      #pragma once
      #ifndef HICONEDITOR_H
      #define HICONEDITOR_H
      #include <QWidget>
      //!@ HIConEditor 类描述
      //!@ 类名:HIConEditor
      //!@ 基类名:QWidget
      //!@ 文件名称:e:\DrawLine\test\HIConEditor.h
      //!@ 创建者:Administrator
      //!@ 创建时间: 2014/03/29 17:26:33
      //!@ 类描述:

      class HIConEditor:public QWidget
      {
      Q_OBJECT
      Q_PROPERTY(QImage iconImage READ GetIConImage WRITE SetIConImage)
      Q_PROPERTY(QColor penColor READ GetPenColor WRITE SetPenColor)
      Q_PROPERTY(int zoomFactor READ GetZoomFactor WRITE SetZoomFactor)
      public:
      HIConEditor(QWidget *pParent=0);

      void SetPenColor(const QColor &newColor);
      inline QColor GetPenColor()const{return m_curColor;}
      void SetIConImage(const QImage &newImage);
      inline QImage GetIConImage()const{return m_curImage;}
      void SetZoomFactor(const int nZoom);
      inline int GetZoomFactor()const{return m_nZoom;}

      //!@重写基类函数
      QSize sizeHint()const;

      //!@ 重写基类函数
      protected:
      void mousePressEvent(QMouseEvent * event);
      void mouseMoveEvent(QMouseEvent * event);
      void paintEvent(QPaintEvent * event);

      private:
      void SetImagePixel(const QPoint &ptPosition,bool bOpaque);
      QRect GetPixelRect( const int nX, const int nY);

      private:
      QColor m_curColor;
      QImage m_curImage;
      int m_nZoom;
      };

      #endif
      @
      @#include <QPainter>
      #include <QPaintEvent>
      #include "HIConEditor.h"
      HIConEditor::HIConEditor( QWidget pParent/=0*/ )
      :QWidget(pParent)
      {
      setAttribute(Qt::WA_StaticContents);
      setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
      m_curColor=Qt::black;
      m_nZoom=8;
      m_curImage=QImage(16,16,QImage::Format_ARGB32);//w,h
      m_curImage.fill(qRgba(0,0,0,0));
      }

      QSize HIConEditor::sizeHint() const
      {
      QSize qSize=m_nZoom*m_curImage.size();
      if (m_nZoom>=3)
      {
      qSize+=QSize(1,1);
      }
      return qSize;
      }

      void HIConEditor::SetPenColor( const QColor &newColor )
      {
      if (newColor != m_curColor)
      {
      m_curColor=newColor;
      }
      }

      void HIConEditor::SetIConImage( const QImage &newImage )
      {
      if (newImage !=m_curImage)
      {
      m_curImage=newImage.convertToFormat(QImage::Format_ARGB32);
      update();
      updateGeometry();
      }
      }

      void HIConEditor::SetZoomFactor( const int nZoom )
      {
      if (nZoom !=m_nZoom)
      {
      if (nZoom<1)
      {
      m_nZoom=nZoom;
      update();
      updateGeometry();
      }
      }
      }

      void HIConEditor::paintEvent( QPaintEvent * event )
      {
      QPainter painter(this);
      if (m_nZoom>=3)
      {
      painter.setPen(palette().foreground().color());
      for (int i=0;i<=m_curImage.width();i++)
      {
      painter.drawLine(m_nZoomi,0,m_nZoomi,m_nZoomm_curImage.height());
      }
      for(int i=0;i<=m_curImage.height();i++)
      {
      painter.drawLine(0,m_nZoom
      i,m_nZoomm_curImage.width(),m_nZoomi);
      }
      }
      for(int i=0;i<m_curImage.width();i++)
      {
      for(int j=0;j<m_curImage.height();j++)
      {
      QRect rect=GetPixelRect(i,j);
      if (!event->region().intersect(rect).isEmpty())
      {
      QColor color=QColor::fromRgba(m_curImage.pixel(i,j));
      if (color.alpha()<255)
      {
      painter.fillRect(rect,Qt::white);
      }
      else
      {
      painter.fillRect(rect,color);
      }
      }
      }
      }
      }

      QRect HIConEditor::GetPixelRect( const int nX, const int nY )
      {
      if (m_nZoom>=3)
      {
      return QRect(m_nZoomnX+1,m_nZoomnY+1,m_nZoom-1,m_nZoom-1);//(x,y,w,h)
      }
      else
      {
      return QRect(m_nZoomnX,m_nZoomnY,m_nZoom,m_nZoom);
      }
      }

      void HIConEditor::mousePressEvent( QMouseEvent * event )
      {
      if (event->button()==Qt::LeftButton)
      {
      SetImagePixel(event->pos(),true);
      }
      else if (event->button()==Qt::RightButton)
      {
      SetImagePixel(event->pos(),false);
      }
      }

      void HIConEditor::SetImagePixel( const QPoint &ptPosition,bool bOpaque )
      {
      int i=ptPosition.x()/m_nZoom;
      int j=ptPosition.y()/m_nZoom;
      if (m_curImage.rect().contains(i,j))
      {
      if (bOpaque)
      {
      m_curImage.setPixel(i,j,GetPenColor().rgba());
      }
      else
      {
      m_curImage.setPixel(i,j,qRgba(0,0,0,0));
      }
      update(GetPixelRect(i,j));
      }
      }

      void HIConEditor::mouseMoveEvent( QMouseEvent * event )
      {
      if (event->buttons()&Qt::LeftButton)
      {
      SetImagePixel(event->pos(),true);
      }
      else if (event->buttons()&Qt::RightButton)
      {
      SetImagePixel(event->pos(),false);
      }
      }
      @
      @#pragma once
      #ifndef HICONEDITORPLUGIN_H
      #define HICONEDITORPLUGIN_H
      #include <QDesignerCustomWidgetInterface>
      class HIconEditorPlugin :public QObject,public QDesignerCustomWidgetInterface
      {
      Q_OBJECT
      Q_INTERFACES(QDesignerCustomWidgetInterface) //告知qt这个类实现的是QDesignerCustomWidgetInterface接口
      public:
      HIconEditorPlugin(QObject*pParent=0);

      //!@ 重写
      QString name()const;
      //!@ 重写
      QString includeFile()const;
      //!@ 重写
      QString group()const;
      //!@ 重写
      QIcon icon()const;
      //!@ 重写
      QString toolTip()const;
      //!@ 重写
      QString whatsThis()const;
      //!@ 重写
      bool isContainer()const;
      //!@ 重写
      QWidget createWidget(QWidget parent);
      };
      #endif
      @
      @
      #include "HIconEditorPlugin.h"
      #include "HIConEditor.h"
      #include "qplugin.h"
      HIconEditorPlugin::HIconEditorPlugin( QObject
      pParent/
      =0*/ )
      :QObject(pParent)
      {

      }

      QString HIconEditorPlugin::name() const
      {
      return "HIConEditor";
      }

      QString HIconEditorPlugin::includeFile() const
      {
      return "HIConEditor.h";
      }

      QString HIconEditorPlugin::group() const
      {
      return tr("Image Manipulation Widgets");
      }

      QIcon HIconEditorPlugin::icon() const
      {
      return QIcon(":/images/iconeditor.png");
      }

      QString HIconEditorPlugin::toolTip() const
      {
      return tr("An icon editor widget");
      }

      QString HIconEditorPlugin::whatsThis() const
      {
      return tr("This widget is presented in Chapter 5 of <i>C++ GUI"
      "Programming with Qt 4</i> as example of a custom Qt"
      "widget.");
      }

      bool HIconEditorPlugin::isContainer() const
      {
      return false;
      }

      QWidget * HIconEditorPlugin::createWidget( QWidget *parent )
      {
      return new HIConEditor(parent);
      }
      Q_EXPORT_PLUGIN2(hiconeditorplugin,HIconEditorPlugin)@

      为什么下面这个QImage属性在QDesigner设计器中不显示,而其他定义的属性正常显示。
      !C:\Users\Administrator\Desktop\QQ图片20140330192657.jpg(F:\QQ图片20140330192657.jpg)!Q_PROPERTY(QImage iconImage READ GetIConImage WRITE SetIConImage)

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qq897425998
        wrote on last edited by
        #57

        今天才发现 官网资源 这么丰富 以后就用官的论坛了

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qq897425998
          wrote on last edited by
          #58

          今天才发现 官网资源 这么丰富 以后就用官的论坛了 就是访问这网站慢了点

          1 Reply Last reply
          0
          • W Offline
            W Offline
            William_YY
            wrote on last edited by
            #59

            都是2011年的回帖,没人了么。

            1 Reply Last reply
            0
            • C Offline
              C Offline
              CloudCastle
              wrote on last edited by
              #60

              我是武汉的,一直在玩百度贴吧
              第一次到这边来,请多多关照~

              a laptop and a book, a cup of coffee with one person.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                smallghost
                wrote on last edited by
                #61

                新人报道!!!

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  deleted487
                  wrote on last edited by
                  #62

                  测试一下

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    deleted487
                    wrote on last edited by
                    #63

                    test from Chrome

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      jiangcaiyang
                      wrote on last edited by
                      #64

                      Test from Chrome V35 for Windows.

                      1 Reply Last reply
                      0
                      • W Offline
                        W Offline
                        wuhuan
                        wrote on last edited by
                        #65

                        安装的时候,需要用户认证,出现ssl握手失败导致无法下一步安装,要怎么解决?

                        joeQJ 1 Reply Last reply
                        0
                        • W wuhuan

                          安装的时候,需要用户认证,出现ssl握手失败导致无法下一步安装,要怎么解决?

                          joeQJ Offline
                          joeQJ Offline
                          joeQ
                          wrote on last edited by
                          #66

                          @wuhuan 您好!

                          对于新的问题,可以发布新的Post。

                          请问您安装的是Qt的哪一个版本?安装的时候,是可以skip跳过用户这一步骤的。安装开始界面有一个skip button。

                          Just do it!

                          1 Reply Last reply
                          0
                          • Crawl.WC Offline
                            Crawl.WC Offline
                            Crawl.W
                            wrote on last edited by
                            #67

                            可以的,只是限制了国际友人支持的难度

                            1 Reply Last reply
                            0
                            • P Offline
                              P Offline
                              Princein
                              wrote on last edited by
                              #68

                              加油 go go go

                              1 Reply Last reply
                              0
                              • gaosiyG Offline
                                gaosiyG Offline
                                gaosiy
                                wrote on last edited by
                                #69

                                打卡中文论坛!
                                跟大佬们学习

                                Biomedical Engineering Ph.D. student, China

                                1 Reply Last reply
                                0
                                • Z zhxt

                                  那必须的! :)

                                  [quote author="Chuck Gao" date="1311946372"]
                                  [quote author="Xingtao Zhang" date="1311940164"]关注下,人气儿不怎么高啊![/quote]

                                  恩,目前才20个人,求给力!

                                  [/quote]

                                  J Offline
                                  J Offline
                                  jinyu
                                  wrote on last edited by
                                  #70

                                  @zhxt 您好,qt新手,有没有qt creator的下载地址呢?

                                  JKSHJ 1 Reply Last reply
                                  0
                                  • J jinyu

                                    @zhxt 您好,qt新手,有没有qt creator的下载地址呢?

                                    JKSHJ Offline
                                    JKSHJ Offline
                                    JKSH
                                    Moderators
                                    wrote on last edited by
                                    #71

                                    @jinyu said in 欢迎大家来到Qt中文论坛:

                                    您好,qt新手,有没有qt creator的下载地址呢?

                                    https://www.qt.io/download

                                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                    crazyErrorC 1 Reply Last reply
                                    0
                                    • crazyErrorC Offline
                                      crazyErrorC Offline
                                      crazyError
                                      wrote on last edited by
                                      #72

                                      您好,qt小白,想请问一下,在vs2015中新建qt项目(一路默认)为什么没有自动生成GeneratedFile文件夹

                                      1 Reply Last reply
                                      0
                                      • JKSHJ JKSH

                                        @jinyu said in 欢迎大家来到Qt中文论坛:

                                        您好,qt新手,有没有qt creator的下载地址呢?

                                        https://www.qt.io/download

                                        crazyErrorC Offline
                                        crazyErrorC Offline
                                        crazyError
                                        wrote on last edited by
                                        #73

                                        @JKSH 您好,qt小白,想请问一下,在vs2015中新建qt项目(一路默认)为什么没有自动生成GeneratedFile文件夹

                                        1 Reply Last reply
                                        0
                                        • S Offline
                                          S Offline
                                          SphinX
                                          Banned
                                          wrote on last edited by
                                          #74

                                          新人来报个到~希望能和大家多多交流

                                          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