I apologize before hand for asking what I am sure is a very noobish question, but after looking around google for hours, I just can't figure out how to find an answer to my question, nor where to start looking in c++ documentation. My suspicion is that it has to do with my ignorance towards function pointers.
Now, something like this makes sense to me:
.h snippet
QList<QToolButton *> *list_Button;
QList<QToolButton *> *list_Button;
QToolButton *card_AbandonedMine;
To copy to clipboard, switch view to plain text mode
.cpp snippet
list_Button->append(card_AbandonedMine);
card_AbandonedMine=new QToolButton;
list_Button->append(card_AbandonedMine);
To copy to clipboard, switch view to plain text mode
which I might make a loop like this:
void DominionLinux::createCards()
{
for( int i = 0; i < list.size(); i++ )
{
list_Button->at(i)->setCheckable(true);
}
}
void DominionLinux::createCards()
{
for( int i = 0; i < list.size(); i++ )
{
list_Button->at(i)->setCheckable(true);
}
}
To copy to clipboard, switch view to plain text mode
That all works perfectly, and my hope is that I can also add function slots into this. The reason I can't use just one type of function, is because each slot has unique arguments.
Now as far as creating some sort of list, I have tried applying the same principle to a member function/slot, but the closest I have come is for my program to run, but then unexpectantly crash. I went in with basically the same mindset:
.h snippet
QList<void *> *list_Slots;
private slot:
void *SLOTcard_AbandonedMine(bool Checked=false, bool matchOpponent=false);;
QList<void *> *list_Slots;
private slot:
void *SLOTcard_AbandonedMine(bool Checked=false, bool matchOpponent=false);;
To copy to clipboard, switch view to plain text mode
.cpp snippet
void* DominionLinux::SLOTcard_AbandonedMine(bool Checked, bool TryMatchOpponent)
{
if (Checked == true)
{
ui->verticalLayout_Enabled->addWidget(card_AbandonedMine);
}
else if (Checked == false)
{
ui->verticalLayout_Disabled->addWidget(card_AbandonedMine);
}
}
void DominionLinux::createList()
{
connect(card_AbandonedMine,SIGNAL(toggled(bool)), this, SLOT(SLOTcard_AbandonedMine(bool)));
list_Slots->append(SLOTcard_AbandonedMine(false,false)); // If I disable this line, my program will work fine
}
void* DominionLinux::SLOTcard_AbandonedMine(bool Checked, bool TryMatchOpponent)
{
if (Checked == true)
{
ui->verticalLayout_Enabled->addWidget(card_AbandonedMine);
}
else if (Checked == false)
{
ui->verticalLayout_Disabled->addWidget(card_AbandonedMine);
}
}
void DominionLinux::createList()
{
connect(card_AbandonedMine,SIGNAL(toggled(bool)), this, SLOT(SLOTcard_AbandonedMine(bool)));
list_Slots->append(SLOTcard_AbandonedMine(false,false)); // If I disable this line, my program will work fine
}
To copy to clipboard, switch view to plain text mode
And it stops with this message:
The inferior stopped because it received a signal from the Operating System.
Signal name :
SIGSEGV
Signal meaning :
Segmentation fault
and this is the output
g++ -o DominionLinux main.o DominionLinux.o qrc_cards.o moc_DominionLinux.o -lQt5Widgets -L/usr/lib/i386-linux-gnu -lQt5Network -lQt5Gui -lQt5Core -lGL -lpthread
{ test -n "" && DESTDIR="" || DESTDIR=.; } && test $(gdb --version | sed -e 's,[^0-9]\+\([0-9]\)\.\([0-9]\).*,\1\2,;q') -gt 72 && gdb --nx --batch --quiet -ex 'set confirm off' -ex "save gdb-index $DESTDIR" -ex quit 'DominionLinux' && test -f DominionLinux.gdb-index && objcopy --add-section '.gdb_index=DominionLinux.gdb-index' --set-section-flags '.gdb_index=readonly' 'DominionLinux' 'DominionLinux' && rm -f DominionLinux.gdb-index || true
08:08:12: The process "/usr/bin/make" exited normally.
08:08:13: Elapsed time: 00:07.
All I really want is just a very base and simple example of how to make some sort of list for a function/ member function/ slot (if there is a difference), so I can call it in an iterator loop.
Hope this made sense~ Thanks in advance.
Bookmarks