欢迎大家来到Qt中文论坛



  • 新人报道,哦耶。



  • 捧场,捧场来啦,弱弱的问一下,那个视频怎么看不起喃



  • YouTube的视频在大陆看不起。
    [quote author="jayjie" date="1374976398"]捧场,捧场来啦,弱弱的问一下,那个视频怎么看不起喃[/quote]



  • 新人报道~从百度贴吧过来...



  • I'm coming.



  • 新人报道



  • 我装的QT5.2,然后编译时提示没有compiler,请问该怎么弄呢?我时新手,呵呵



  • 一直不知有个中文的版块,一直用Qt遇到的问题是很多,因为英文表达比较差,所以很少提问,很多的问题都是靠自己反复阅读英文文档才搞明白,以后至少可以在这里向大家提提问。



  • 新人来报个到.



  • @
    #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)



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



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



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



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



  • 新人报道!!!



  • 测试一下



  • test from Chrome



  • Test from Chrome V35 for Windows.



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



  • @wuhuan 您好!

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

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.