Hi,
in my application the ui is not able to reach the buttons it has inside, and I don't understand why. I've done some similar applications and I never had a problem...
I'm just adding two button to the ui file, using the Qt Creator, but the message "class xxx has no member called" is shown. I'm pretty sure it's a stupid mistake but I'm not able to figure out what can be happening. I've tried recompiling few times, delenting manually the files (tmp, moc...), deleting the ui file and creating again from the start, removing it from the project and adding it again...
UI file
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CanicasClass</class>
<widget class="QMainWindow" name="CanicasClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>270</width>
<height>202</height>
</rect>
</property>
<property name="windowTitle">
<string>Canicas</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QFrame" name="m_wdgChoseLvl">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QScrollArea" name="m_scrollArea">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>226</width>
<height>140</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="m_btnLevel1">
<property name="text">
<string>Rising Star</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_btnLevel2">
<property name="text">
<string>Level 2</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CanicasClass</class>
<widget class="QMainWindow" name="CanicasClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>270</width>
<height>202</height>
</rect>
</property>
<property name="windowTitle">
<string>Canicas</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QFrame" name="m_wdgChoseLvl">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QScrollArea" name="m_scrollArea">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>226</width>
<height>140</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="m_btnLevel1">
<property name="text">
<string>Rising Star</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_btnLevel2">
<property name="text">
<string>Level 2</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
To copy to clipboard, switch view to plain text mode
.h code
#ifndef CANICAS_H
#define CANICAS_H
#include <QtGui/QMainWindow>
#include "ui_canicas.h"
/*namespace Ui {
class Canicas;
}*/
{
Q_OBJECT
public:
explicit Canicas
(QWidget *parent
= 0);
~Canicas();
private:
Ui::CanicasClass ui;
void setConnections();
};
#endif // CANICAS_H
#ifndef CANICAS_H
#define CANICAS_H
#include <QtGui/QMainWindow>
#include "ui_canicas.h"
/*namespace Ui {
class Canicas;
}*/
class Canicas : public QMainWindow
{
Q_OBJECT
public:
explicit Canicas(QWidget *parent = 0);
~Canicas();
private:
Ui::CanicasClass ui;
void setConnections();
};
#endif // CANICAS_H
To copy to clipboard, switch view to plain text mode
.cpp
#include "canicas.h"
#include "ui_canicas.h"
#include <QPushButton>
Canicas
::Canicas(QWidget *parent
) :{
ui.setupUi(this);
setConnections();
}
Canicas::~Canicas()
{
}
void Canicas::setConnections()
{
//ui.m_btnLevel1->scroll(0, 0); //Don't display an error
connect(ui.m_btnLvl1, SIGNAL(clicked()),
this, SLOT(level1()));
/*QObject::connect(ui.m_btnLvl2, SIGNAL(clicked()),
this, SLOT(level2()));*/
}
#include "canicas.h"
#include "ui_canicas.h"
#include <QPushButton>
Canicas::Canicas(QWidget *parent) :
QMainWindow(parent)
{
ui.setupUi(this);
setConnections();
}
Canicas::~Canicas()
{
}
void Canicas::setConnections()
{
//ui.m_btnLevel1->scroll(0, 0); //Don't display an error
connect(ui.m_btnLvl1, SIGNAL(clicked()),
this, SLOT(level1()));
/*QObject::connect(ui.m_btnLvl2, SIGNAL(clicked()),
this, SLOT(level2()));*/
}
To copy to clipboard, switch view to plain text mode
Bookmarks