код:
.pro
:
Код:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
help_botton.cpp \
main.cpp \
what.cpp
HEADERS += \
HelpBrowser.h \
help_botton.h \
what.h
FORMS += \
what.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
1.qrc
:
Код:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
help_botton.cpp \
main.cpp \
what.cpp
HEADERS += \
HelpBrowser.h \
help_botton.h \
what.h
FORMS += \
what.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
1.qrc
:
Код:
#ifndef HELP_BOTTON_H
#define HELP_BOTTON_H
#include <QObject>
#include "HelpBrowser.h"
class help_botton : public QObject
{
Q_OBJECT
public:
explicit help_botton(QObject *parent = nullptr);
QPushButton* help;
private slots:
void help_clicked()
{
HelpBrowser helpBrowser("V:\\project for qt\\book lesons\\What\\ToolTip_what", "help.htm");
helpBrowser.resize(450, 300);
helpBrowser.show();
}
};
#endif // HELP_BOTTON_H
:
Код:
#ifndef _HelpBrowser_h_
#define _HelpBrowser_h_
#include "qpushbutton.h"
#include "qtextbrowser.h"
#include <QtGui>
#include <QVBoxLayout>
class HelpBrowser : public QWidget
{
Q_OBJECT
public:
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);
}
};
#endif //_HelpBrowser_h_
Код:
#include "help_botton.h"
#include "qobjectdefs.h"
#include "what.h"
#include <QApplication>
#include <QObject>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
what w;
help_botton h;
h.help->show();
w.show();
return a.exec();
}
:
Код:
#include "what.h"
#include "qobjectdefs.h"
#include "ui_what.h"
#include <QtGui>
what::what(QMainWindow *parent): QMainWindow(parent), ui(new Ui::what)
{
ui->setupUi(this);
this->setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
this->setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
this->setWindowFlag(Qt::WindowCloseButtonHint, false);
setWindowTitle(" ");
}
:
Код:
#ifndef WHAT_H
#define WHAT_H
#include <QMainWindow>
#include <QtGui>
#include <QObject>
QT_BEGIN_NAMESPACE
namespace Ui { class what; }
QT_END_NAMESPACE
class what : public QMainWindow
{
Q_OBJECT
public:
what(QMainWindow *parent = nullptr);
protected slots:
private:
Ui::what *ui;
};
#endif // WHAT_H
:
Код:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>what</class>
<widget class="QMainWindow" name="what">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>613</width>
<height>467</height>
</rect>
</property>
<property name="cursor">
<cursorShape>ForbiddenCursor</cursorShape>
</property>
<property name="windowTitle">
<string>what</string>
</property>
<property name="windowIcon">
<iconset resource="1.qrc">
<normaloff>:/1/icon.png</normaloff>:/1/icon.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QPushButton" name="cloes">
<property name="geometry">
<rect>
<x>-10</x>
<y>-10</y>
<width>641</width>
<height>481</height>
</rect>
</property>
<property name="toolTip">
<string><html><head/><body><p align="center"><span style=" font-size:48pt; color:#ffff00;">button</span></p></body></html></string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>621</width>
<height>451</height>
</rect>
</property>
<property name="toolTip">
<string><html><head/><body><p align="center"><span style=" font-size:48pt; color:#ffff00;">Button</span></p></body></html></string>
</property>
<property name="text">
<string><html><head/><body><p><br/></p></body></html></string>
</property>
</widget>
</widget>
</widget>
<resources>
<include location="1.qrc"/>
</resources>
<connections>
<connection>
<sender>cloes</sender>
<signal>clicked()</signal>
<receiver>what</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>190</x>
<y>461</y>
</hint>
<hint type="destinationlabel">
<x>493</x>
<y>466</y>
</hint>
</hints>
</connection>
</connections>
</ui>
ошибок нет но вывод приложения:
12:32:34: Starting V:/project for qt/book lesons/What/build-ToolTip_what-Desktop_Qt_6_3_1_MinGW_64_bit-Debug/debug/ToolTip_what.exe...
12:32:38: V:/project for qt/book lesons/What/build-ToolTip_what-Desktop_Qt_6_3_1_MinGW_64_bit-Debug/debug/ToolTip_what.exe crashed.
и оно не запускается подскажите из-за чего?