Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

помощь новичку

$
0
0
не пойму в чем ошибка, помогите кому не трудно (скорее всего ошибка в написании\ применении класса майвиджет) Запускается D:\qt\projS\build-ComboCounter-Desktop_Qt_5_0_2_MinGW_32bit-Debug\debug\ComboCounter… QWidget: Must construct a QApplication before a QPaintDevice Invalid parameter passed to C runtime function. Invalid parameter passed to C runtime function. Error – RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly D:\qt\projS\build-ComboCounter-Desktop_Qt_5_0_2_MinGW_32bit-Debug\debug\ComboCounter завершился с кодом 3 combocounter.h #ifndef COMBOCOUNTER_H #define COMBOCOUNTER_H   #include <QMainWindow> #include <QObject>   namespace Ui { class counter; }   class combocounter : public QObject {     Q_OBJECT private:     int Value;     public:     combocounter(); public slots:     void slotInc();   signals:     void goodbye ();     void counterChanged(int);     };   #endif // COMBOCOUNTER_H MyWidget.h #ifndef MYWIDGET_H #define MYWIDGET_H   #include <QWidget> #include <QComboBox>   class MyWidget: public QWidget {   Q_OBJECT   public:   MyWidget (QWidget* _parent = 0);   private slots:   void mySlot (QString _text);   private:   QComboBox *cmb;   }; #endif // MYWIDGET_H combocounter.cpp #include "combocounter.h"   combocounter::combocounter() :     QObject()   ,Value(0)   {   }   void combocounter::slotInc() {     emit counterChanged(++Value) ; } main.cpp #include "combocounter.h" #include "MyWidget.h" #include <QApplication> #include <QLayout> #include <QPushButton> #include <QComboBox> #include <QDIal> #include <QTimeEdit> #include <QSpinBox> #include <QTimer> #include <QListWidget> #include <QLabel>   int main(int argc, char *argv[]) {     QApplication a(argc, argv);     QWidget  w;     QComboBox* cmb = new QComboBox;     QPushButton* btn = new QPushButton("Добавить");       QDial* dial = new QDial;     QTimeEdit* time = new QTimeEdit;     QSpinBox* spb = new QSpinBox;       QLabel* lbl = new QLabel("AAA");         QTimer* timer = new QTimer;     timer->start(1000);   //combobox items     cmb->addItem("Counter1");     cmb->addItem("Counter2");     cmb->addItem("Counter3"); //hidding   dial->hide();   time->hide();   spb->hide();               if (lbl->text() == "Counter1") {            QObject::connect(btn, SIGNAL(clicked()),                             dial, SLOT (show())                            );             }         if (cmb->currentText() == "Counter2") {          QObject::connect(btn, SIGNAL(clicked()),                           time, SLOT (show())                          );           }        if (cmb->currentText() == "Counter3") {          QObject::connect(btn, SIGNAL(clicked()),                           spb, SLOT (show())                          );         }      //dial start     combocounter counter1;       QObject::connect(timer, SIGNAL(timeout()),                      &counter1, SLOT (slotInc())             );     QObject::connect(&counter1, SIGNAL(counterChanged(int)),                      dial, SLOT (setValue(int))             );   //timeedit start     combocounter counter2;       QObject::connect(timer, SIGNAL(timeout()),                      &counter2, SLOT (slotInc())             );     QObject::connect(&counter2, SIGNAL(counterChanged(int)),                      time, SLOT (stepUp())             );   //spinbox start     combocounter counter3;       QObject::connect(timer, SIGNAL(timeout()),                      &counter3, SLOT (slotInc())             );     QObject::connect(&counter3, SIGNAL(counterChanged(int)),                      spb, SLOT (setValue(int))             );         //Layout setup      QVBoxLayout* lay = new QVBoxLayout;      lay->addWidget(cmb);      lay->addWidget(btn);      lay->addStretch(1);      lay->addWidget(dial);      lay->addWidget(time);      lay->addWidget(spb);      lay->addWidget(lbl);      lay->setMargin(30);      lay->setSpacing(15);        w.setLayout (lay);           w.resize(200,360);     w.show();         return a.exec();     } MyWidget.cpp #include "MyWidget.h" #include <QComboBox> #include <QLabel> #include <QDial> #include <QLabel> #include <QPushButton>     QPushButton* btn = new QPushButton("Добавить");   QDial* dial = new QDial;   QLabel* lbl = new QLabel("AAA");   MyWidget::MyWidget (QWidget* _parent): QWidget (_parent) {   cmb = new QComboBox (this);       connect(cmb, SIGNAL(currentTextChanged(QString)),           this, SLOT (mySlot(QString))); }   void MyWidget::mySlot(QString _text) {   lbl->setText (_text);   if (_text == "dial")     connect(btn, SIGNAL(clicked()),             dial, SLOT (show())); }

Viewing all articles
Browse latest Browse all 13965