Mein Ziel ein gui zu erstellen das die Toolbar Buttons das gewünschte dialoge anzeigen im Gleichen MainWindow.
Am anfang hatte ich das komplette mainwindow die buttons gleich ins
Toolbar intrgriert mti dem designer dann STacked widget in mainwindow noch
Eben wollte Das 1 Toolbar button das die erste seite vom stacked widget anzeigt aber das ging mit dem designer nicht es zu verknüpfen.
da hat mir einer gesagt das es so nicht geht man muss als source via
cpp oder py machen.
jetzt habe ich stacked widget wieder ruasgeschmissen und die einzelenen
dialoge eine seperates .ui erstellt.
wie nach einem beispiel wo ich es gesehen habe.
Es sol momentan nur ein funktionierendes gui werden ohne core.
hier ist ein fehler das bei mir kommt:
mit make:
C
ich kann die fehler nicht fixen kein ahunung wie das kommt.onnectionsDialog.h:31: error: using-declaration for non-member at class scope
ConnectionsDialog.h:31: error: expected `;' before "ui"
ConnectionsDialog.cpp: In constructor `ConnectionsDialog::ConnectionsDialog(QWid
get*)':
ConnectionsDialog.cpp:13: error: `ui' undeclared (first use this function)
ConnectionsDialog.cpp:13: error: (Each undeclared identifier is reported only on
ce for each function it appears in.)
mingw32-make[1]: *** [release\ConnectionsDialog.o] Error 1
mingw32-make[1]: Leaving directory `E:/QT-2'
mingw32-make: *** [release] Error 2
hier mein Mainwindow.cpp:
Code: Alles auswählen
#include "MainWindow.h"
/* 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_PREFERENCES ":/images/preferences_24x24.png"
#define IMAGE_CHAT ":/images/comments_24x24.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));
/* Create the toolbar */
ui.toolBar->addActions(grp->actions());
ui.toolBar->addSeparator();
connect(grp, SIGNAL(triggered(QAction *)), ui.stackPages, SLOT(showPage(QAction *)));
/* 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);
}
connectionsdialog.h:
Code: Alles auswählen
#ifndef _CONNECTIONSDIALOG_H
#define _CONNECTIONSDIALOG_H
#include <QFileDialog>
#include "configpage.h"
#include "ui_ConnectionsDialog.h"
class ConnectionsDialog : public ConfigPage
{
Q_OBJECT
public:
/** Default Constructor */
ConnectionsDialog(QWidget *parent = 0);
/** Default Destructor */
~ConnectionsDialog();
/** Saves the changes on this page */
/** Loads the settings for this page */
private slots:
private:
/** Qt Designer generated object */
Ui::ConnectionsDialog ui;
};
#endifCode: Alles auswählen
#include "ConnectionsDialog.h"
/** Constructor */
ConnectionsDialog::ConnectionsDialog(QWidget *parent)
: ConfigPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
/* Hide platform specific features */
#ifdef Q_WS_WIN
ui.grpPermissions->setVisible(false);
#endif
}
wer kann sagen wieso?
wie ich es fixen muss?