当前位置: 代码迷 >> QT开发 >> QT中难以解决的有关问题
  详细解决方案

QT中难以解决的有关问题

热度:65   发布时间:2016-04-25 04:15:32.0
QT中难以解决的问题

/********************dialog.h****************************/
#include <QApplication>
#include<QWidget>
#include<QtGui>
#include"printtext.h"

class Dialogs : public QWidget
{
    Q_OBJECT
public:
    Dialogs();
private:
    QFrame *frame;
    QPushButton  *button0; 
    QPushButton  *button1;
    QPushButton  *button2;
    QTextEdit    *textEdit;
private slots:
    void slotbutton0();
    void slotbutton1();
    void slotbutton2();
   // void slotbutton3();

};

/********************dialog.cpp****************************/
#include <QApplication>
#include<stdio.h>
#include<unistd.h>
#include <QtGui>
#include"printtext.h"
#include"dialog.h"

QFile file("printer.txt");
int pid;

Dialogs:ialogs( )


  frame=new QFrame(this);
  button0=new QPushButton(this); 
  button1=new QPushButton(this); 
  button2=new QPushButton(this); 
   frame->setObjectName("myframe");
   frame->resize(320,240); 
   frame->setStyleSheet("QFrame#myframe{border-image:url(images/background.png)}" );

   button0->setGeometry(260,30,50,50);
   button1->setGeometry(260,90,50,50);
   button2->setGeometry(260,150,50,50);

   QIcon icon;
   QPixmap pixmap0("images/Start_amended.png");
   icon.addPixmap(pixmap0);
   button0->setIcon(icon);
   button0->setIconSize(QSize(50,50));
   button0->setFixedSize(pixmap0.size());
   button0->setMask(pixmap0.mask());

   QPixmap pixmap1("images/Stop_amended.png");
   icon.addPixmap(pixmap1);
   button1->setIcon(icon);
   button1->setIconSize(QSize(50,50));
   button1->setFixedSize(pixmap1.size());
   button1->setMask(pixmap1.mask());


   QPixmap pixmap2("images/set.png");
   icon.addPixmap(pixmap2);
   button2->setIcon(icon);
   button2->setIconSize(QSize(50,50));
   button2->setFixedSize(pixmap2.size());
   button2->setMask(pixmap2.mask());

   connect(button0,SIGNAL(clicked()),this,SLOT(slotbutton0()));
   connect(button1,SIGNAL(clicked()),this,SLOT(slotbutton1()));
   connect(button2,SIGNAL(clicked()),this,SLOT(slotbutton2()));
//  connect(button3,SIGNAL(clicked()),this,SLOT(slotbutton3()));

}

void Dialogs::slotbutton0()
{                              
  execlp("sh","sh","hello.sh",NULL);
  pid=getpid();       
}    

void Dialogs::slotbutton1()
{                              
  相关解决方案