#include <QApplication>#include <QTranslator>#include <QTPlugin>#include <QFile>#include <QTGui>#include <QtUiTools> Q_IMPORT_PLUGIN(qjpeg) Q_IMPORT_PLUGIN(qgif) Q_IMPORT_PLUGIN(qkrcodecs)#include "proga1.h"/* Заставка */ void loadModules(QSplashScreen* psplash) { QTime time; time.start(); for (int i = 0; i < 100; ) { if (time.elapsed() > 40) { time.start(); ++i; } psplash->showMessage("Loading: " + QString::number(i) + "%", Qt::AlignHCenter | Qt::AlignBottom, Qt::black); } } int main (int argc, char **argv) { QApplication app(argc, argv); QSplashScreen splash(QPixmap("./image/zastavka.png")); splash.show(); MainWindow w; loadModules (&splash) ; getchar(); splash.finish (&w); w.show(); return app.exec(); }
#ifndef PROGA1_H#define PROGA1_H#include <QMainWindow>#include <QTranslator>#include <QFile>#include <QObject>#include "ui_proga1.h"class MainWindow : public QMainWindow, Ui::MainWindow // <--------Наследуемся{ Q_OBJECTpublic: .............. QFile* file; MainWindow(QMainWindow* p = 0) : QMainWindow(p) { file = new QFile(this);
#ifndef PROGA1HELPBROWSER_H#define PROGA1HELPBROWSER_H#include <QtGui>class HelpBrowser : public QWidget{ Q_OBJECTpublic: HelpBrowser(const QString& strPath, const QString& strFileName, QWidget* pwgt = 0) : QWidget(pwgt) { QPushButton* pcmdBack = new QPushButton ("<<"); QPushButton* pcmdHome = new QPushButton("Home"); QPushButton* pcmdForward = new QPushButton (">>"); QTextBrowser* ptxtBrowser = new QTextBrowser; connect(pcmdBack, SIGNAL(clicked()), ptxtBrowser, SLOT(backward())); connect(pcmdHome, SIGNAL(clicked()), ptxtBrowser, SLOT(home())); connect(pcmdForward, SIGNAL(clicked()), ptxtBrowser, SLOT(forward())); connect(ptxtBrowser, SIGNAL(backwardAvailable(bool)), pcmdBack, SLOT(setEnabled(bool))); connect(ptxtBrowser, SIGNAL(forwardAvailable(bool)), pcmdForward, SLOT(setEnabled(bool))); ptxtBrowser->setSearchPaths(QStringList() << strPath); ptxtBrowser->setSource(QString(strFileName)); //Layout setup QVBoxLayout* pvbxLayout = new QVBoxLayout; QHBoxLayout* phbxLayout = new QHBoxLayout; phbxLayout->addWidget(pcmdBack); phbxLayout->addWidget(pcmdHome); phbxLayout->addWidget(pcmdForward); pvbxLayout->addLayout(phbxLayout); pvbxLayout->addWidget(ptxtBrowser); setLayout(pvbxLayout); } HelpBrowser(QWidget *parent = 0); bool event(QEvent* e);};#endif // PROGA1HELPBROWSER_H
...........void MainWindow::helpBrowser(){ this->setWindowModality(Qt::NonModal); HelpBrowser helpbrowser("doc", "./help/index.htm"); helpbrowser.resize(400, 300); helpbrowser.show();}
Выполняется сборка проекта Pr1...Настройки не изменились, этап QMake пропускается.Запускается: C:/MinGW/bin/mingw32-make.exe -w mingw32-make: Entering directory `C:/Pr1'C:/MinGW/bin/mingw32-make -f Makefile.Releasemingw32-make[1]: Entering directory `C:/Pr1'g++ -c -O2 -fno-exceptions -Wall -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -DQT_NO_DYNAMIC_CAST -I"..\Qt\4.6.0\include\QtUiTools" -I"..\Qt\4.6.0\include\QtCore" -I"..\Qt\4.6.0\include\QtGui" -I"..\Qt\4.6.0\include\QtXml" -I"..\Qt\4.6.0\include" -I"." -I"..\Qt\4.6.0\include\ActiveQt" -I"release" -I"." -I"..\Qt\4.6.0\mkspecs\win32-g++" -o release\main.o main.cppg++ -c -O2 -fno-exceptions -Wall -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -DQT_NO_DYNAMIC_CAST -I"..\Qt\4.6.0\include\QtUiTools" -I"..\Qt\4.6.0\include\QtCore" -I"..\Qt\4.6.0\include\QtGui" -I"..\Qt\4.6.0\include\QtXml" -I"..\Qt\4.6.0\include" -I"." -I"..\Qt\4.6.0\include\ActiveQt" -I"release" -I"." -I"..\Qt\4.6.0\mkspecs\win32-g++" -o release\proga1.o proga1.cppC:/Qt/4.6.0/bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -DQT_NO_DYNAMIC_CAST -I"..\Qt\4.6.0\include\QtUiTools" -I"..\Qt\4.6.0\include\QtCore" -I"..\Qt\4.6.0\include\QtGui" -I"..\Qt\4.6.0\include\QtXml" -I"..\Qt\4.6.0\include" -I"." -I"..\Qt\4.6.0\include\ActiveQt" -I"release" -I"." -I"..\Qt\4.6.0\mkspecs\win32-g++" -D__GNUC__ -DWIN32 proga1.h -o release\moc_proga1.cppg++ -c -O2 -fno-exceptions -Wall -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -DQT_NO_DYNAMIC_CAST -I"..\Qt\4.6.0\include\QtUiTools" -I"..\Qt\4.6.0\include\QtCore" -I"..\Qt\4.6.0\include\QtGui" -I"..\Qt\4.6.0\include\QtXml" -I"..\Qt\4.6.0\include" -I"." -I"..\Qt\4.6.0\include\ActiveQt" -I"release" -I"." -I"..\Qt\4.6.0\mkspecs\win32-g++" -o release\moc_proga1.o release\moc_proga1.cppC:/Qt/4.6.0/bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -DQT_NO_DYNAMIC_CAST -I"..\Qt\4.6.0\include\QtUiTools" -I"..\Qt\4.6.0\include\QtCore" -I"..\Qt\4.6.0\include\QtGui" -I"..\Qt\4.6.0\include\QtXml" -I"..\Qt\4.6.0\include" -I"." -I"..\Qt\4.6.0\include\ActiveQt" -I"release" -I"." -I"..\Qt\4.6.0\mkspecs\win32-g++" -D__GNUC__ -DWIN32 proga1_helpbrowser.h -o release\moc_proga1_helpbrowser.cppg++ -c -O2 -fno-exceptions -Wall -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -DQT_NO_DYNAMIC_CAST -I"..\Qt\4.6.0\include\QtUiTools" -I"..\Qt\4.6.0\include\QtCore" -I"..\Qt\4.6.0\include\QtGui" -I"..\Qt\4.6.0\include\QtXml" -I"..\Qt\4.6.0\include" -I"." -I"..\Qt\4.6.0\include\ActiveQt" -I"release" -I"." -I"..\Qt\4.6.0\mkspecs\win32-g++" -o release\moc_proga1_helpbrowser.o release\moc_proga1_helpbrowser.cppg++ -static -static-libgcc -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-subsystem,windows -o pr1.exe object_script.pr1.Release -L"c:\Qt\4.6.0\lib" -lmingw32 -lqtmain -LC:/Qt/4.6.0/plugins/imageformats -lqjpeg -lqgif -LC:/Qt/4.6.0/plugins/codecs -lqkrcodecs -lQtUiTools -lQtXml -lQtGui -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtCore -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws2_32mingw32-make[1]: Leaving directory `C:/Pr1'mingw32-make: Leaving directory `C:/Pr1'./release\moc_proga1_helpbrowser.o:moc_proga1_helpbrowser.cpp:(.rdata$_ZTV11HelpBrowser[vtable for HelpBrowser]+0x1c): undefined reference to `HelpBrowser::event(QEvent*)'collect2: ld returned 1 exit statusmingw32-make[1]: *** [pr1.exe] Error 1mingw32-make: *** [release] Error 2Завершено с кодом возврата 2.Ошибка во время сборки проекта Pr1Во время выполнения сборки на этапе 'Make'
HelpBrowser(QWidget *parent = 0); bool event(QEvent* e);
C++ (Qt)void MainWindow::helpBrowser(){ HelpBrowser *helpbrowser = new HelpBrowser("doc", "./help/index.htm"); helpbrowser->resize(400, 300); helpbrowser->show();}
QFile file("./log.txt"); if (file.open(QIODevice::WriteOnly)) { QTextStream out(&file); out << "This is log-file" << endl(); }
C:/Pr1/../Qt/4.6.0/include/QtCore/../../src/corelib/io/qtextstream.h:320: error: too few arguments to function 'QTextStream& endl(QTextStream&)'C:/Pr1/main.cpp:40: error: at this point in file
QFile file("./log.txt"); file.open(QIODevice::WriteOnly); QTextStream out(&file); out << "This is log-file" << endl; out << "This is :)" << endl; file.close();
C++ (Qt) QFile file("./log.txt"); file.open(QIODevice::WriteOnly); QTextStream out(&file); (out << "This is log-file").endl(); (out << "This is :)").endl(); file.close();
C++ (Qt) QFile file("./log.txt"); file.open(QIODevice::WriteOnly); QTextStream out(&file); out << "This is log-file"; endl(out); out << "This is :)"; endl(out); file.close();