• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            Cpper
            C/C++高級(jí)工程師 Android高級(jí)軟件工程師 IT集成工程師 音頻工程師 熟悉c,c++,java,c#,py,js,asp等多種語言 程序猿

            使用QT Designer設(shè)計(jì)軟件界面
            使用過程沒什么說的

            假定生成的ui文件如下:
            <?xml version="1.0" encoding="UTF-8"?>
            <ui version="4.0">
             
            <class>Form</class>
             
            <widget class="QWidget" name="Form">
              
            <property name="geometry">
               
            <rect>
                
            <x>0</x>
                
            <y>0</y>
                
            <width>203</width>
                
            <height>177</height>
               
            </rect>
              
            </property>
              
            <property name="windowTitle">
               
            <string>Form</string>
              
            </property>
              
            <widget class="QWidget" name="">
               
            <property name="geometry">
                
            <rect>
                 
            <x>20</x>
                 
            <y>20</y>
                 
            <width>164</width>
                 
            <height>139</height>
                
            </rect>
               
            </property>
               
            <layout class="QVBoxLayout" name="verticalLayout_3">
                
            <item>
                 
            <widget class="QLineEdit" name="lineEdit"/>
                
            </item>
                
            <item>
                 
            <layout class="QHBoxLayout" name="horizontalLayout">
                  
            <item>
                   
            <layout class="QVBoxLayout" name="verticalLayout_2">
                    
            <item>
                     
            <widget class="QPushButton" name="pushButton_7">
                      
            <property name="text">
                       
            <string>PushButton</string>
                      
            </property>
                     
            </widget>
                    
            </item>
                    
            <item>
                     
            <widget class="QPushButton" name="pushButton_5">
                      
            <property name="text">
                       
            <string>PushButton</string>
                      
            </property>
                     
            </widget>
                    
            </item>
                    
            <item>
                     
            <widget class="QPushButton" name="pushButton">
                      
            <property name="text">
                       
            <string>PushButton</string>
                      
            </property>
                     
            </widget>
                    
            </item>
                   
            </layout>
                  
            </item>
                  
            <item>
                   
            <layout class="QVBoxLayout" name="verticalLayout">
                    
            <item>
                     
            <widget class="QPushButton" name="pushButton_2">
                      
            <property name="text">
                       
            <string>PushButton</string>
                      
            </property>
                     
            </widget>
                    
            </item>
                    
            <item>
                     
            <widget class="QPushButton" name="pushButton_8">
                      
            <property name="text">
                       
            <string>PushButton</string>
                      
            </property>
                     
            </widget>
                    
            </item>
                    
            <item>
                     
            <widget class="QPushButton" name="pushButton_4">
                      
            <property name="text">
                       
            <string>PushButton</string>
                      
            </property>
                     
            </widget>
                    
            </item>
                   
            </layout>
                  
            </item>
                 
            </layout>
                
            </item>
               
            </layout>
              
            </widget>
             
            </widget>
             
            <resources/>
             
            <connections/>
            </ui>
            然后修改pro文件
            加入對(duì)QUitools的鏈接
            CONFIG += uitools
            其main.cpp如下:
            #include <QFile>
            #include 
            <QtGui/QApplication>
            #include 
            <QtGui/QWidget>
            #include 
            <QtGui/QLineEdit>
            #include 
            <QtUiTools/QuiLoader>

            int main(int argc, char *argv[])
            {
                QApplication a(argc, argv);
                QUiLoader ui;
                QFile file(
            "dlg.ui");
                QWidget
            * widget = ui.load(&file);
                
            if(widget)
                {
                    widget
            ->setWindowTitle("Dlg");
                    QLineEdit
            * lineedit = widget->findChild<QLineEdit*>("lineEdit");
                    lineedit
            ->setStyleSheet("QLineEdit {background-color: yellow}");
                    lineedit
            ->setText("information.");
                    widget
            ->show();
                }
                
            return a.exec();
            }
            posted @ 2011-08-05 22:01 ccsdu2009 閱讀(939) | 評(píng)論 (0)編輯 收藏
             
            #include <QtGui/QApplication>
            #include 
            <QtGui/QScrollArea>
            #include 
            "widget.h"

            int main(int argc, char *argv[])
            {
                QApplication a(argc, argv);
                Widget 
            *widget = new Widget;

                QScrollArea area;
                area.setWidget(widget);
                area.viewport()
            ->setBackgroundRole(QPalette::Dark);
                area.viewport()
            ->setAutoFillBackground(true);
                area.setWindowTitle(
            "Icon Cool");
                area.show();

                
            return a.exec();
            }
            posted @ 2011-08-03 22:37 ccsdu2009 閱讀(471) | 評(píng)論 (0)編輯 收藏
             
            #include <QColor>
            #include 
            <QImage>
            #include 
            <QtGui/QWidget>

            class Widget : public QWidget
            {
                Q_OBJECT
                Q_PROPERTY(QColor penColor READ penColor WRITE setPenColor)
                Q_PROPERTY(QImage iconImage READ iconImage WRITE setIconImage)
                Q_PROPERTY(
            int zoomFactor READ zoomFactor WRITE setZoomFactor)
            public:
                Widget(QWidget 
            *parent = 0);
                
            ~Widget();

                
            void   setPenColor(const QColor& newColor);
                QColor penColor()
            const{return curColor;}
                
            void   setZoomFactor(int newZoom);
                
            int    zoomFactor()const{return zoom;}
                
            void   setIconImage(const QImage& image);
                QImage iconImage()
            const{return image;}
                QSize  sizeHint()
            const;
            protected:
                
            void   mousePressEvent(QMouseEvent *event);
                
            void   mouseMoveEvent(QMouseEvent* event);
                
            void   paintEvent(QPaintEvent* event);
            private:
                
            void   setImagePixel(const QPoint &pos,bool opaque);
                QRect  pixelRect(
            int i,int j)const;

                QColor curColor;
                QImage image;
                
            int    zoom;
            };

            #include <QtGui>
            #include "widget.h"
            Widget::Widget(QWidget *parent)
             : QWidget(parent)
            {
             this->setAttribute(Qt::WA_StaticContents);
             this->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
             this->curColor = Qt::black;
             this->zoom = 8;
             image = QImage(16,16,QImage::Format_ARGB32);
             image.fill(qRgba(0,0,0,0));
            }
            Widget::~Widget()
            { 
            }
            QSize Widget::sizeHint()const
            {
             QSize size = zoom * image.size();
             if(zoom >= 3)
             size += QSize(1,1);
             return size;
            }
            void Widget::setPenColor(const QColor& newColor)
            {
             curColor = newColor;
            }
            void Widget::setIconImage(const QImage& image)
            {
             if(this->image != image)
             {
             this->image = image.convertToFormat(QImage::Format_ARGB32);
             update();
             this->updateGeometry();
             }
            }
            void Widget::paintEvent(QPaintEvent* event)
            {
             QPainter painter(this);
             if(zoom >=3)
             {
             painter.setPen(this->palette().foreground().color());
             for(int i = 0; i <= image.width();++i)
             painter.drawLine(zoom*i,0,zoom*i,zoom*image.height());
             for(int j = 0;j <= image.height();j++)
             painter.drawLine(0,zoom*j,zoom*image.width(),zoom*j);
             }
             for(int i = 0; i < image.width();i++)
             {
             for(int j = 0;j < image.height();j++)
             {
             QRect rect = this->pixelRect(i,j);
             if(!event->region().intersect(rect).isEmpty())
             {
             QColor color = QColor::fromRgba(image.pixel(i,j));
             if(color.alpha() < 255)
             painter.fillRect(rect,Qt::white);
             painter.fillRect(rect,color);
             }
             }
             }
            }
            QRect Widget::pixelRect(int i, int j) const
            {
             if(zoom >=3)
             return QRect(zoom*i+1,zoom*j+1,zoom-1,zoom-1);
             return QRect(zoom*i,zoom*j,zoom,zoom);
            }
            void Widget::mousePressEvent(QMouseEvent *event)
            {
             if(event->button() == Qt::LeftButton)
             setImagePixel(event->pos(),true);
             else if(event->button() == Qt::RightButton)
             setImagePixel(event->pos(),false);
            }
            void Widget::mouseMoveEvent(QMouseEvent *event)
            {
             if(event->buttons() & Qt::LeftButton)
             setImagePixel(event->pos(),true);
             else if(event->buttons() & Qt::RightButton)
             setImagePixel(event->pos(),false);
            }
            void Widget::setImagePixel(const QPoint &pos, bool opaque)
            {
             int i = pos.x()/zoom;
             int j = pos.y()/zoom;
             if(image.rect().contains(i,j))
             {
             if(opaque)
             image.setPixel(i,j,penColor().rgba());
             else
             image.setPixel(i,j,qRgba(0,0,0,0));
             this->update(this->pixelRect(i,j));
             }
            }
            void Widget::setZoomFactor(int newZoom)
            {
             if(newZoom < 1)
             newZoom = 1;
             if(newZoom != zoom)
             {
             zoom = newZoom;
             update();
             updateGeometry();
             }
            }
            幾點(diǎn)說明:
            1.宏 Q_PROPERTY 聲明屬性讀寫屬性
            2.setSizePolicy(.,.) 說明控件最小尺寸為推薦尺寸
            3.sizeHint() 獲得控件推薦尺寸
            4.控件 update()/updateGeometry()用于下次重繪和調(diào)整控件尺寸
            5.在函數(shù)paintEvent中繪制圖元
            6.一個(gè)控件的調(diào)色板有3個(gè)顏色組 激活,非激活,不可用
            posted @ 2011-08-03 22:15 ccsdu2009 閱讀(1193) | 評(píng)論 (0)編輯 收藏
             
            MainWindow::MainWindow(QWidget *parent)
                : QMainWindow(parent)
            {
                edit 
            = new QTextEdit;
                
            this->setCentralWidget(edit);
                setAcceptDrops(
            true);
                
            this->setWindowTitle(tr("Text Editor"));
            }

            MainWindow::
            ~MainWindow()
            {
            }

            void MainWindow::dragEnterEvent(QDragEnterEvent* event)
            {
                
            if(event->mimeData()->hasFormat("text/uri-list"))
                    
            event->acceptProposedAction();
            }

            void MainWindow::dropEvent(QDropEvent* event)
            {
                QList
            <QUrl> uri = event->mimeData()->urls();
                
            if(uri.isEmpty())
                    
            return;
                QString file 
            = uri.first().toLocalFile();
                
            if(file.isEmpty())
                    
            return;
                
            this->setWindowTitle(tr("%1 -- %2").arg(file).arg("Drag File"));
            }
            posted @ 2011-08-02 22:39 ccsdu2009 閱讀(534) | 評(píng)論 (0)編輯 收藏
             
            一個(gè)簡(jiǎn)單的使用例子如下:
            #include "mainwindow.h"
            #include 
            <QtGui/QDockWidget>
            #include 
            <QtGui/QTextEdit>

            MainWindow::MainWindow(QWidget 
            *parent)
                : QMainWindow(parent)
            {
                QDockWidget
            * widget = new QDockWidget(tr("DockWidget"));
                QTextEdit
            * edit = new QTextEdit;
                widget
            ->setWidget(edit);
                widget
            ->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
                
            this->addDockWidget(Qt::LeftDockWidgetArea,widget);
            }

            MainWindow::
            ~MainWindow()
            {

            }
            需要說明的是僅MainWidow僅可設(shè)置Dock
            posted @ 2011-08-02 22:16 ccsdu2009 閱讀(789) | 評(píng)論 (0)編輯 收藏
             
            #include <QtGui/QApplication>
            #include 
            <QtGui/QTextEdit>
            #include 
            <QtGui/QSplitter>

            int main(int argc, char *argv[])
            {
                QApplication a(argc, argv);

                QTextEdit
            * text1 = NULL;
                QTextEdit
            * text2 = NULL;
                QSplitter
            * splitter;
                text1 
            = new QTextEdit;
                text2 
            = new QTextEdit;
                splitter 
            = new QSplitter(Qt::Vertical);
                splitter
            ->addWidget(text1);
                QTextEdit
            * text3 = new QTextEdit;
                QSplitter
            * sp1 = new QSplitter(Qt::Horizontal);
                splitter
            ->addWidget(text2);
                splitter
            ->setStretchFactor(1,1);
                sp1
            ->addWidget(splitter);
                sp1
            ->addWidget(text3);
                sp1
            ->show();
                
            return a.exec();
            }
            posted @ 2011-08-02 21:52 ccsdu2009 閱讀(635) | 評(píng)論 (0)編輯 收藏
             
            接上文
            一個(gè)簡(jiǎn)單的基于QT的程序啟動(dòng)畫面代碼為:
            #include <QtGui/QApplication>
            #include 
            <QtGui/QSplashScreen>
            #include 
            <QtGui/QPixmap>
            #include 
            "registerdlg.h"

            int main(int argc, char *argv[])
            {
                QApplication a(argc, argv);
                QSplashScreen
            * splash = new QSplashScreen(QPixmap("DevCPP.bmp"));
                splash
            ->show();

                RegisterDlg w;

                
            //! load some data

                Qt::Alignment topright 
            = Qt::AlignRight | Qt::AlignTop;
                splash
            ->showMessage(QObject::tr("Loading addins"),topright,Qt::blue);

                
            //! load soma data

                
            for(int i = 0;i< 9999;i++)
                    ;

                w.show();
                splash
            ->finish(&w);
                delete splash;
                
            return a.exec();
            }
            posted @ 2011-08-01 22:16 ccsdu2009 閱讀(500) | 評(píng)論 (0)編輯 收藏
             
            還不太完善
            #ifndef REGISTER_DLG_H
            #define REGISTER_DLG_H

            #include 
            <QtGui/QDialog>
            #include 
            <QtGui/QVBoxLayout>
            #include 
            <QtGui/QHBoxLayout>
            #include 
            <QtGui/QGridLayout>
            #include 
            <QtGui/QLabel>
            #include 
            <QtGui/QLineEdit>
            #include 
            <QtGui/QPushButton>

            class RegisterDlg : public QDialog
            {
                Q_OBJECT
            public:
                RegisterDlg(QWidget 
            *parent = 0);
                
            ~RegisterDlg();
            public slots:
                
            void checkRegister();
            private:
                QVBoxLayout
            *  layout;
                QLabel
            *       label;
                QGridLayout
            *  gridlayout;
                QLabel
            *       namelabel;
                QLineEdit
            *    nameedit;
                QLabel
            *       codelabel;
                QLineEdit
            *    codeedit;
                QHBoxLayout
            *  hlayout;
                QPushButton
            *  confirm;
                QPushButton
            *  cancel;
            };

            #endif
            //! ccsdu2004
            cxx
            #include <QtGui/QMessageBox>
            #include 
            "registerdlg.h"

            RegisterDlg::RegisterDlg(QWidget 
            *parent)
                : QDialog(parent)
            {
                layout 
            = new QVBoxLayout;
                label  
            = new QLabel(tr("Please input register info below"));
                layout
            ->addWidget(label);
                gridlayout 
            = new QGridLayout;
                namelabel  
            = new QLabel(tr("User Name"));
                nameedit   
            = new QLineEdit();
                codelabel  
            = new QLabel(tr("Register Code"));
                codeedit   
            = new QLineEdit();
                gridlayout
            ->addWidget(namelabel,0,0);
                gridlayout
            ->addWidget(nameedit,0,1);
                gridlayout
            ->addWidget(codelabel,1,0);
                gridlayout
            ->addWidget(codeedit,1,1);
                layout
            ->addLayout(gridlayout);
                hlayout 
            = new QHBoxLayout;
                confirm 
            = new QPushButton(tr("Confirm"));
                cancel  
            = new QPushButton(tr("Cancel"));
                hlayout
            ->addWidget(confirm);
                hlayout
            ->addWidget(cancel);
                layout
            ->addLayout(hlayout);
                
            this->setLayout(layout);
                
            this->setWindowTitle(tr("Register"));

                connect(
            this->cancel,SIGNAL(clicked()),this,SLOT(close()));
                connect(
            this->confirm,SIGNAL(clicked()),this,SLOT(checkRegister()));
            }

            RegisterDlg::
            ~RegisterDlg()
            {
            }

            void RegisterDlg::checkRegister()
            {
            }
            posted @ 2011-08-01 21:55 ccsdu2009 閱讀(802) | 評(píng)論 (0)編輯 收藏
             
            最近感覺都在瞎忙乎
            無論是GUI還是Audio Effect都不能帶來收益
            學(xué)了幾年編程
            現(xiàn)在發(fā)現(xiàn)居然對(duì)UI編程還處于一年級(jí)水平
            需要提高UI編程能力啊
            這簡(jiǎn)直就是大BUG
            posted @ 2011-07-31 22:16 ccsdu2009 閱讀(477) | 評(píng)論 (1)編輯 收藏
             
            int strncasecomp(char const *str1, char const *str2, unsigned long len)
            {
                signed 
            int c1 = 0, c2 = 0;

                
            while (len--)
                {
                    c1 
            = tolower(*str1++);
                    c2 
            = tolower(*str2++);

                    
            if (c1 == 0 || c1 != c2)
                        
            break;
                }

                
            return c1 - c2;
            }
            posted @ 2011-06-16 22:43 ccsdu2009 閱讀(1457) | 評(píng)論 (0)編輯 收藏
            僅列出標(biāo)題
            共38頁: First 17 18 19 20 21 22 23 24 25 Last 
             
            久久国产色AV免费观看| 亚洲综合婷婷久久| 亚洲成人精品久久| 久久久久久久97| 国产精品亚洲综合专区片高清久久久| 一本久久免费视频| 99久久人人爽亚洲精品美女| 久久午夜福利无码1000合集 | 久久99精品国产麻豆婷婷| 久久久久亚洲AV片无码下载蜜桃| 999久久久免费国产精品播放| 欧美黑人又粗又大久久久| 久久婷婷人人澡人人| 99久久精品国产综合一区| 丰满少妇高潮惨叫久久久| 久久亚洲中文字幕精品一区| 久久最新免费视频| 国产福利电影一区二区三区久久久久成人精品综合 | 国产激情久久久久影院老熟女| 无码伊人66久久大杳蕉网站谷歌| 欧美粉嫩小泬久久久久久久 | 四虎亚洲国产成人久久精品| 情人伊人久久综合亚洲| 国内精品伊人久久久久av一坑| 久久精品国产精品亚洲精品 | 88久久精品无码一区二区毛片 | 国内精品久久久久久久久| 久久国产一区二区| 久久免费视频观看| 国内精品久久久久影院免费| 国产精品99久久99久久久| 久久久无码精品亚洲日韩按摩| 亚洲伊人久久精品影院| 久久精品国产亚洲αv忘忧草| 色天使久久综合网天天| 久久久久亚洲AV成人网人人网站| 久久久久99这里有精品10| 思思久久99热只有频精品66| 少妇熟女久久综合网色欲| 中文字幕乱码人妻无码久久| 一本色道久久综合亚洲精品|