Mój kod pojawia się poniżej. Kiedy próbuję skompilować to uzyskać:porównanie między QAbstractButton i QPushButton * brakuje obsady
error: 29:38 comparison between distinct pointer types QAbstractButton and QPushButton* lacks a cast -> 'if (stdmetBox.clickedButton() == stdButton)'
System: Amazon Kindle Fire 7" z systemem CyanogenMod 11.0 (Android 4.4.2 Kitkat) Compiler: G ++/gcc (GCC dla C4droid wtyczki wersji 4.9.1) IDE: C4droid z SDL, GCC i ministro plugins
Każda pomoc będzie bardzo mile widziane rozglądałem ale jedyny przypadek znajdę iOS jest specyficzny
#include <fstream>
#include <QApplication>
#include <QLabel>
#include <QMessageBox>
#include <QString>
#include <QAbstractButton>
#include <QInputDialog>
#include <QDebug>
using namespace std;
int setup()
{
string unitchar;
string unitcharo;
bool setupSuccess;
int returncode;
QMessageBox msgBox;
QMessageBox stdmetBox;
QMessageBox ynBox;
msgBox.setText("Welcome to Tyler's Fitness App! This app will help you with your fitness goals, whatever they may be. Let's get you set up!");
msgBox.exec();
QPushButton *stdButton = stdmetBox.addButton(QT_TR_NOOP("Standard"), QMessageBox::ActionRole);
QPushButton *metButton = stdmetBox.addButton(QT_TR_NOOP("Metric"), QMessageBox::ActionRole);
stdmetBox.exec();
if (stdmetBox.clickedButton() == stdButton)
{
unitchar = "standard";
unitcharo = "metric";
}
else if (stdmetBox.clickedButton() == metButton)
{
unitchar = "metric";
unitcharo = "standard";
}
else
{
setupSuccess = false;
returncode = 0;
return returncode;
}
if (unitchar == "standard")
{
ynBox.setInformativeText("Standard units include feet, miles, mph, pounds, etc.");
}
else
{
ynBox.setInformativeText("Metric units include meters, kilometers, kph, kilograms, etc.");
}
QPushButton *yesButton = ynBox.addButton(QT_TR_NOOP("Yes"), QMessageBox::ActionRole);
QPushButton *noButton = ynBox.addButton(QT_TR_NOOP("No"), QMessageBox::ActionRole);
ynBox.setText("Is that okay?")
while (ynBox.clickedButton() == noButton)
{
if (unitchar == "standard")
{
unitchar = "metric";
unitcharo = "standard";
}
else
{
unitchar = "standard";
unitcharo = "metric";
}
if (unitchar == "standard")
{
ynBox.setInformativeText("Standard units include feet, miles, mph, pounds, etc.");
}
else
{
ynBox.setInformativeText("Metric units include meters, kilometers, kph, kilograms, etc.");
}
result = ynBox.exec();
}
if (unitchar == "standard")
{
msgBox.setText("Great! You've selected standard units.");
msgBox.exec();
setupSuccess = true;
}
else
{
msgBox.setText("Great! You've selected metric units.");
msgBox.exec();
setupSuccess = true;
}
if (setupSuccess != true)
{
returncode = 0;
}
else if (unitchar == "standard")
{
returncode = 1;
}
else
{
returncode = 2;
}
return returncode;
}
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
unitmaster = setup();
if ((unitmaster == 1) || (unitmaster == 2))
{
QMessageBox successBox;
successBox.setText("The program has completed successfully!");
successBox.exec();
}
else
{
QMessageBox errorBox;
errorBox.setText("The program has completed successfully!");
errorBox.exec();
}
return app.exec();
}
Wydaje się, że zapomniałeś dołączyć '' nawet jeśli używasz 'QPushButton' w sposób, który wymaga jego definicji. Jeden z nagłówków musiał go zadeklarować, ponieważ został rozpoznany jako klasa, ale jeśli jest niekompletny, kompilator nie wiedziałby, że 'QPushButton *' można przekształcić w 'QAbstractButton *'. Spróbuj dodać brakujący element i sprawdź, czy to rozwiąże problem. –
user2079303
Poszedłem do przodu i napisałem to jako odpowiedź, ponieważ jestem pewien, że to twój problem, mimo że nie jestem w stanie przetestować siebie. – user2079303