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

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: [solved]Странное поведени приложения при вызове QmessageBox::about  (Прочитано 3265 раз)
Unnamed_Hero
Гость
« : Мая 16, 2009, 13:15 »

Qt 4.5.1, Slackware, qt creator 1.1
Простейшее приложение. главная форма не рисуется, только иконка в трее. там единственный пункт меню, вызывающий QMessageBox::about. После нажатия ОК на окошке QMesageBox программа выходит, что весьма странно.
Код:
/home/unnamed_hero/work/qt/testa/testa exited with code 0
Где я не прав?

main.cpp
Код:
#include <QtGui/QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    return a.exec();
}

mainwindow.h
Код:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QMainWindow>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QAction>
#include <QMessageBox>
namespace Ui
{
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    QSystemTrayIcon *nTray;
  QMenu * trayMenu;
//    QAction * exitAction;
//    QAction * optionsAction;
    QAction * aboutAction;
    void initMenu ();
   private slots:
    void aboutShow ();
};

#endif // MAINWINDOW_H


mainwindow.cpp
Код:
#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
 nTray = new QSystemTrayIcon (QIcon ("/usr/share/icons/MOPSIcons4/48x48/places/start-here-kde.png"),this);
   trayMenu = new QMenu ();
   initMenu ();
   nTray->show();
}

MainWindow::~MainWindow()
{
    delete ui;
    delete aboutAction;
}
void MainWindow::initMenu()
 {
    aboutAction = new QAction (QIcon (":/icons/gnome-stock-about.png"), tr ("&About"), this);
    connect (aboutAction, SIGNAL (triggered()), this, SLOT (aboutShow ()));
    trayMenu->addAction(aboutAction);
    nTray->setContextMenu(trayMenu);
 }
 void MainWindow::aboutShow()
 {
 QMessageBox::about (0, tr ("About foo"), tr ("foo is rocks \n"
                                                                          "and best af all"));
 }
« Последнее редактирование: Мая 16, 2009, 15:10 от Unnamed_Hero » Записан
Rcus
Гость
« Ответ #1 : Мая 16, 2009, 13:44 »

Цитировать
quitOnLastWindowClosed : bool

This property holds whether the application implicitly quits when the last window is closed.

The default is true.

If this property is true, the applications quits when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed. By default this attribute is set for all widgets except for sub-windows. Refer to Qt::WindowType for a detailed list of Qt::Window objects.
Записан
Unnamed_Hero
Гость
« Ответ #2 : Мая 16, 2009, 15:09 »

Да, спасибо. Почти сам дошёл до этого.
Записан
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


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