[gelöst]Kann Preferences Dialog nicht ausführen
Verfasst: 8. August 2006 12:37
hi
ich habe mir ein Gui und noch dazu extra das PreferencesWindow Dialog
das Dialog will ich via Toolbar button vom gui ausführen.
habe schon eine methode gefunden aber es kommen fehler..
MainWindow.cpp
MainWindow.h
ok hier nun der fehler:
ich habe mir ein Gui und noch dazu extra das PreferencesWindow Dialog
das Dialog will ich via Toolbar button vom gui ausführen.
habe schon eine methode gefunden aber es kommen fehler..
MainWindow.cpp
Code: Alles auswählen
#include <QString>
#include <QtDebug>
#include <QIcon>
#include "MainWindow.h"
#include "Preferences/PreferencesWindow.h"
#define FONT QFont(tr("Arial"), 8)
/* Images for toolbar icons */
#define IMAGE_CONNECTIONS ":/images/connections_24x24.png"
#define IMAGE_PEERS ":/images/peers_24x24.png"
#define IMAGE_SEARCH ":/images/search_24x24.png"
#define IMAGE_DOWNLOADS ":/images/downloads_24x24.png"
#define IMAGE_SHARED_FILES ":/images/sharedfiles_24x24.png"
#define IMAGE_UPLOADS ":/images/uploads_24x24.png"
#define IMAGE_PREFERENCES ":/images/preferences_24x24.png"
#define IMAGE_CHAT ":/images/chats_24x24.png"
#define IMAGE_RSHARE ":/images/RShare16.png"
/** Constructor */
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
{
/* Invoke the Qt Designer generated QObject setup routine */
ui.setupUi(this);
/* Create the config pages and actions */
QActionGroup *grp = new QActionGroup(this);
ui.stackPages->add(new ConnectionsDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_CONNECTIONS), tr("Connections"), grp));
ui.stackPages->add(new PeersDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_PEERS), tr("Peers"), grp));
ui.stackPages->add(new SearchDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_SEARCH), tr("Search"), grp));
ui.stackPages->add(new DownloadsDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_DOWNLOADS), tr("Downloads"), grp));
ui.stackPages->add(new UploadsDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_UPLOADS), tr("Uploads"), grp));
ui.stackPages->add(new ChatDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_CHAT), tr("Chat"), grp));
ui.stackPages->add(new SharedFilesDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_SHARED_FILES), tr("Shared Files"), grp));
/* Create the toolbar */
ui.toolBar->addActions(grp->actions());
ui.toolBar->addSeparator();
connect(grp, SIGNAL(triggered(QAction *)), ui.stackPages, SLOT(showPage(QAction *)));
/* Create and bind the Preferences button */
addAction(new QAction(QIcon(IMAGE_PREFERENCES), tr("Preferences"), ui.toolBar),
SLOT(showPreferencesWindow()));
/* Select the first action */
grp->actions()[0]->setChecked(true);
}
/** Creates a new action associated with a config page. */
QAction*
MainWindow::createPageAction(QIcon img, QString text, QActionGroup *group)
{
QAction *action = new QAction(img, text, group);
action->setCheckable(true);
action->setFont(FONT);
return action;
}
/** Adds the given action to the toolbar and hooks its triggered() signal to
* the specified slot (if given). */
void
MainWindow::addAction(QAction *action, const char *slot)
{
action->setFont(FONT);
ui.toolBar->addAction(action);
connect(action, SIGNAL(triggered()), this, slot);
}
/** Overloads the default show so we can load settings */
void
MainWindow::show()
{
if (!this->isVisible()) {
QMainWindow::show();
} else {
QMainWindow::activateWindow();
setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
QMainWindow::raise();
}
}
/** Shows the config dialog with focus set to the given page. */
void
MainWindow::show(Page page)
{
/* Show the dialog. */
show();
/* Set the focus to the specified page. */
ui.stackPages->setCurrentIndex((int)page);
}
/** Shows Preferences */
void MainWindow::showPreferencesWindow()
{
PreferencesWindow *preferencesWindow = new PreferencesWindow();
preferencesWindow->exec();
}
MainWindow.h
Code: Alles auswählen
#ifndef _MainWindow_H
#define _MainWindow_H
#include <QMainWindow>
#include <QFileDialog>
#include "ConnectionsDialog.h"
#include "PeersDialog.h"
#include "SearchDialog.h"
#include "DownloadsDialog.h"
#include "UploadsDialog.h"
#include "ChatDialog.h"
#include "SharedFilesDialog.h"
#include "ui_MainWindow.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
/** Main dialog pages. */
enum Page {
Connections = 0, /** Connections page. */
Peers = 1, /** Peers page. */
Search = 2, /** Search page. */
Downloads = 3, /** Downloads page. */
Uploads = 4, /** Uploads page. */
Chat = 5, /** Chats page. */
SharedFiles = 6 /** Shared Files page. */
};
/** Default Constructor */
MainWindow(QWidget *parent = 0);
public slots:
/** Called when this dialog is to be displayed */
void show();
/** Shows the config dialog with focus set to the given page. */
void show(Page page);
private slots:
/**void preferences();*/
void showPreferencesWindow();
private:
/** Creates a new action for a config page. */
QAction* createPageAction(QIcon img, QString text, QActionGroup *group);
/** Adds a new action to the toolbar. */
void addAction(QAction *action, const char *slot = 0);
/** Qt Designer generated object */
Ui::MainWindow ui;
};
#endif
ok nun was muss ich machen wegen exec?specs\win32-g++" -o release\MainWindow.o MainWindow.cpp
MainWindow.cpp: In member function `void MainWindow::showPreferencesWindow()':
MainWindow.cpp:126: error: 'class PreferencesWindow' has no member named 'exec'
mingw32-make[1]: *** [release\MainWindow.o] Error 1
mingw32-make[1]: Leaving directory `E:/gui'
mingw32-make: *** [release] Error 2