Título: Hola, alguien podrá ayudarme un poco con este código en c++ y QT4??? Publicado por: Diego_Guadamuz en 7 Diciembre 2011, 21:02 pm #include <QSlider>
#include <QSpinBox> #include <QPushButton> #include <iostream> #include "string.h" using namespace std; string **matrizDeColores; QPushButton **matrizBotones; int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget *window = new QWidget; window->setWindowTitle("Othello 2.0"); QHBoxLayout *layout = new QHBoxLayout(window); matrizBotones = new QPushButton*[8]; for( int i =0;i<8;i++){ matrizBotones= new QPushButton[8]; } for(int i=0;i<8;i++){ for(int j=0;j<8;j++){ matrizBotones[j].setText(" "); matrizBotones[j].setStyleSheet("* { background-color: rgb(200,200,150) }"); matrizBotones[j].setParent(window); matrizBotones[j].setGeometry ( i*60, j*60, 60, 60); QObject::connect(&matrizBotones[j], SIGNAL(clicked()), &matrizBotones[j], SLOT(setStyleSheet("* { background-color: rgb(255,255,255) }");)); //El error es que aunque compila, en tiempo de ejecución muestra que //Object::Connect no sucht slot..., y lo extraño es que la función setStyleSheet si es //un slot de la clase QPushButton que como verán es cada posicion de mi matriz, es //decir, cada matrizBotones[j] es un QPushButton y deberá ejecutar el slot, lo //más extraño es que otras funciones que también son slots pero sin parçametros si //me funcionan sin ningún problema matrizBotones[j].show(); } matrizBotones[3][3].setStyleSheet("* { background-color: rgb(255,255,255) }"); matrizBotones[3][4].setStyleSheet("* { background-color: rgb(0,0,0) }"); matrizBotones[4][3].setStyleSheet("* { background-color: rgb(0,0,0) }"); matrizBotones[4][4].setStyleSheet("* { background-color: rgb(255,255,255) }"); } window->setLayout(layout); window->resize(700,600); window->show(); return app.exec(); } |