Russian Qt Forum
Май 21, 2024, 02:40 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало Форум WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  
  Просмотр сообщений
Страниц: 1 ... 5 6 [7]
91  Qt / Общие вопросы / программа не запускается : Декабрь 28, 2022, 13:25
помогите пожалуйста

код:

.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
help_button.cpp
:
Код:
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
help_button.h
:
Код:
#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
HelpBrowser.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_
main:
Код:
#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();
}
what.cpp
:
Код:
#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(" ");

}
what.pro
:
Код:
#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
what.ui
:
Код:
<?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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:48pt; color:#ffff00;&quot;&gt;button&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:48pt; color:#ffff00;&quot;&gt;Button&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    </property>
    <property name="text">
     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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.


и оно не запускается подскажите из-за чего?
Страниц: 1 ... 5 6 [7]

Страница сгенерирована за 0.123 секунд. Запросов: 23.