Reputation: 3
this is my first question and I'm quite struggeling. I'm using Qt for creating a software for excentric viewing. A group of students did this project before, so I got pre-made code to work with.
My problem is the following one: I am not coding the usual way, I use the QDesigner. I have a Scroll Area where I want to fit some QGroupBoxes inside. There is a general box named "Properties" which holds some other boxes with a vertical layout.
Now one of the boxes is called "symbolgen" and is using a custom class, called "SymbolGen". The class is defined as followed:
class SymbolGen : public QGroupBox
Now what I like to do is to extract alle boxes from the "Properties" box. That means: I want to replace the Group "Properties" by a label "Properties" and underneath with the smaller boxes. Now what Qt says to me is the following:
Fehler: C2664: "SymbolGen::SymbolGen(const SymbolGen &)" : Konvertierung von Argument 1 von "QWidget *" in "QGroupBox *" nicht m”glich
Yes, I am German, in English:
Error: C2664: "SymbolGen::SymbolGen(const SymbolGen &)" : Conversion from argument 1 of "QWidget *" to "QGroupBox *" not possible.
What I see here is, that this specific Group Box "symbolgen" (holds some important variables in the class) needs another group box around. So how can I get this box separated without error?
Thanks for your help!
edit://Line that causes this error:
symbolgen = new SymbolGen(scrollAreaWidgetContents_2);
This one is found at "ui_admin.h".
edit://Definition of "scrollAreaWidgetContents_2" from "ui_admin.h":
scrollAreaWidgetContents_2 = new QWidget();
scrollAreaWidgetContents_2->setObjectName(QStringLiteral("scrollAreaWidgetContents_2"));
scrollAreaWidgetContents_2->setGeometry(QRect(0, 0, 503, 851));
edit://SymbolGen::SymbolGen(const SymbolGen &):
SymbolGen::SymbolGen(QGroupBox *g) : QGroupBox(g)
{
srand (time(NULL));
//Wörterquelle lesen
std::ifstream f("source/ngerman.txt");
std::string l;
if(f.is_open())
{
while(f.good())
{
getline(f,l);
words.push_back(l);
//if( words.size() > 10000 ) break;
}
}
f.close();
//Satzquelle lesen
std::ifstream fs("source/sentences.txt");
//std::string l;
if(fs.is_open())
{
while(fs.good())
{
getline(fs,l);
phrase.push_back(l);
//if( words.size() > 10000 ) break;
}
}
fs.close();
}
Upvotes: 0
Views: 1208
Reputation: 2524
It seems g
is just the parent widget, that is just passed down to the constructor of QGroupBox
, and which should be of type QWidget* instead of QGroupBox*.
You could change that in the declaration, as the QGroupBox
constructor expects a QWidget*
anyway. There may be a reason this was done this way, so the class may rely on the fact that the parent is a group box. Still, I would try to change it and see what happens.
Upvotes: 4