Kein Zugriff mehr auf UI-Elemente



  • Hallo. Seit heute habe ich ein Problem bei dem ich nicht mehr weiter weiß. Gestern lief alles noch wunderbar, aber heute kann ich per ui-> auf keine Elemente mehr Zugreifen. Und es gibt per ui-> aber Elemente die ich garnicht definiert habe.

    mainwindow.h:

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <QCloseEvent>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    protected:
        void closeEvent(QCloseEvent *event);
    
    private:
        Ui::MainWindow *ui;
        bool quitMessageBox();
    
    private slots:
        void about();
        void quit();
    
    };
    
    #endif // MAINWINDOW_H
    

    mainwindow.cpp:

    #include <QMessageBox>
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    //#include "centralwidget.h"
    //#include "insertdialog.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        //setCentralWidget(centralWidget);
        //setWindowIcon(QIcon(":/images/icon.png"));
    
        //createContextMenu();
        //createStatusBar();*/
    
        connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(quit()));
    
        //connect(ui->action_Add_entity, SIGNAL(triggered()), this, SLOT(addEntity()));
        //Wenn ich versuche "action_Add_entity" einzugeben gehts nicht, aber da es hier schon steht läufts. 
        //connect(ui->, SIGNAL(tr)
    
        connect(ui->action_About, SIGNAL(triggered()), this, SLOT(about()));
        connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::closeEvent(QCloseEvent *event)
    {
        if (quitMessageBox()) {
            event->accept();
            QWidget::closeEvent(event);
        } else {
            event->ignore();
        }
    }
    
    bool MainWindow::quitMessageBox()
    {
        if (QMessageBox::question(this, tr("Bla Blubb"),
                                  tr("Do you really want to quit Bla Blubb?"),
                                  QMessageBox::Yes | QMessageBox::No)
                == QMessageBox::Yes) {
            return true;
        }
        return false;
    }
    
    void MainWindow::quit()
    {
        if (quitMessageBox()) {
            qApp->quit();
        }
    }
    
    void MainWindow::about()
    {
        QMessageBox::about(this, tr("Bla Blubb"),
                           tr("<h2>Bla Blubb </h2>"
                              "<p>Copyright &copy; 2012 eddis Softwareimperium</p>"
                              "<p>Bla Blubb is a small application to train Qt<7p>"));
    }
    

    Wenn ich die Actions nochmal versuche manuell einzugeben funktioniert es nicht. Aber da sie da schon stehen läuft das Programm.

    Und noch die .ui -> hier sind doch die Dinge alle vorhanden:

    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>MainWindow</class>
     <widget class="QMainWindow" name="MainWindow">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>392</width>
        <height>292</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>Member - Management</string>
      </property>
      <widget class="QWidget" name="centralWidget"/>
      <widget class="QMenuBar" name="menuBar">
       <property name="geometry">
        <rect>
         <x>0</x>
         <y>0</y>
         <width>392</width>
         <height>20</height>
        </rect>
       </property>
       <widget class="QMenu" name="menu_File">
        <property name="title">
         <string>&amp;File</string>
        </property>
        <addaction name="action_Quit"/>
       </widget>
       <widget class="QMenu" name="menu_Edit">
        <property name="title">
         <string>&amp;Edit</string>
        </property>
        <addaction name="action_Add_entity"/>
        <addaction name="action_Del_entity"/>
       </widget>
       <widget class="QMenu" name="menu_Help">
        <property name="title">
         <string>&amp;Help</string>
        </property>
        <addaction name="action_About"/>
        <addaction name="actionAbout_Qt"/>
       </widget>
       <addaction name="menu_File"/>
       <addaction name="menu_Edit"/>
       <addaction name="menu_Help"/>
      </widget>
      <widget class="QToolBar" name="mainToolBar">
       <attribute name="toolBarArea">
        <enum>TopToolBarArea</enum>
       </attribute>
       <attribute name="toolBarBreak">
        <bool>false</bool>
       </attribute>
       <addaction name="action_Add_entity"/>
       <addaction name="action_Del_entity"/>
      </widget>
      <widget class="QStatusBar" name="statusBar"/>
      <action name="action_Quit">
       <property name="icon">
        <iconset resource="mitgliederverwaltung.qrc">
         <normaloff>:/images/quit.png</normaloff>:/images/quit.png</iconset>
       </property>
       <property name="text">
        <string>&amp;Quit</string>
       </property>
       <property name="shortcut">
        <string>Ctrl+Q</string>
       </property>
      </action>
      <action name="action_Add_entity">
       <property name="icon">
        <iconset resource="mitgliederverwaltung.qrc">
         <normaloff>:/images/add.png</normaloff>:/images/add.png</iconset>
       </property>
       <property name="text">
        <string>&amp;Add entity</string>
       </property>
       <property name="shortcut">
        <string>Ins</string>
       </property>
      </action>
      <action name="action_About">
       <property name="icon">
        <iconset resource="mitgliederverwaltung.qrc">
         <normaloff>:/images/about.png</normaloff>:/images/about.png</iconset>
       </property>
       <property name="text">
        <string>&amp;About</string>
       </property>
      </action>
      <action name="actionAbout_Qt">
       <property name="text">
        <string>About &amp;Qt</string>
       </property>
      </action>
      <action name="action_Del_entity">
       <property name="icon">
        <iconset resource="mitgliederverwaltung.qrc">
         <normaloff>:/images/del.png</normaloff>:/images/del.png</iconset>
       </property>
       <property name="text">
        <string>&amp;Del entity</string>
       </property>
       <property name="shortcut">
        <string>Del</string>
       </property>
      </action>
     </widget>
     <layoutdefault spacing="6" margin="11"/>
     <resources>
      <include location="mitgliederverwaltung.qrc"/>
     </resources>
     <connections/>
    </ui>
    

    noch die main.cpp damit es lauffähig ist:

    #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
    

    Hoffentlich kann mir jemand weiterhelfen.

    Vielen Dank.



  • Hat sich erledigt. Ich habe einfach alle anderen offenen Projekte geschlossen. Jetzt gehts es wieder einwandfrei. Ich habe aber kein Plan warum sich die Projekte da in die Quere kommen.


Anmelden zum Antworten