PDA

View Full Version : extended dialog



arjita
27th July 2012, 20:10
I am new to Qt and reading the following book ..
C++ GUI Programming
with Qt 4 by Jasmin Blanchette
Mark Summerfield
I made the program for shape changing dialogs given in this book.. but somehow program is giving errors:


../sortdialog/main.cpp:7: error: stray '\200' in program
../sortdialog/main.cpp:7: error: stray '\231' in program
../sortdialog/main.cpp:7: error: stray '\342' in program
../sortdialog/main.cpp:7: error: stray '\200' in program
../sortdialog/main.cpp:7: error: stray '\231' in program
../sortdialog/main.cpp:7: error: stray '\342' in program
../sortdialog/main.cpp:7: error: stray '\200' in program
../sortdialog/main.cpp:7: error: stray '\231' in program
../sortdialog/main.cpp:7: error: stray '\342' in program
../sortdialog/main.cpp:7: error: stray '\200' in program
../sortdialog/main.cpp:7: error: stray '\231' in program
../sortdialog/main.cpp: In function 'int main(int, char**)':
../sortdialog/main.cpp:7: error: 'C' was not declared in this scope
../sortdialog/main.cpp:7: error: 'F' was not declared in this scope
make: Leaving directory `/home/arjita/Desktop/practice/extendedDialog/sortdialog-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Release'
make: *** [main.o] Error 1
23:39:14: The process "/usr/bin/make" exited with code 2.
Error while building project sortdialog (target: Desktop)
When executing build step 'Make'

Here I am attaching my folder containing all files of the program .. plz help...
8060

amleto
28th July 2012, 01:16
what is this: ’ ?

It is not valid c++ to use that (as you have). You need to use '.

arjita
28th July 2012, 08:03
ohh thanks I copied from book and made that mistake thanks a lot.. nd plz tell me one more thing
If I include following line in program then the program is finished unexpectedly:
layout()->setSizeConstraint(QLayout::SetFixedSize);
Otherwise it is workin fine ...plz tell..

ChrisW67
31st July 2012, 01:11
If you fix the wrong quotes in main.cpp and sortdialog.cpp your program still does not compile. You need to implement SortDialog::setColumnRange() (it's in the book).

Your program crashes at that line because layout() returns 0. You need to apply a layout to the dialog in Designer.

arjita
31st July 2012, 07:37
Oh I did implement setColumnRange() in my code ... bt I think forgot in the code that I have attached here...and as far as problem with layout()->setSizeConstraint(QLayout::SetFixedSize); is concerned i think forgot to rename the layout in Qt designer....I ll see that thanks...

arjita
31st July 2012, 19:07
Now my code is working fine with no error but the dialog box doesn't hold resize property... here I am giving the snapshots of what is being displayed..
8075
after I click more button following is diaplyed..
8076

and my code...


#include <QtGui>
#include "sortdialog.h"
SortDialog::SortDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
secondaryGroupBox->hide();
tertiaryGroupBox->hide();
formlayout->layout()->setSizeConstraint(QLayout::SetFixedSize);
setColumnRange('A', 'Z');
}
void SortDialog::setColumnRange(QChar first, QChar last)
{
primaryColumnCombo->clear();
secondaryColumnCombo->clear();
tertiaryColumnCombo->clear();
secondaryColumnCombo->addItem(tr("None"));
tertiaryColumnCombo->addItem(tr("None"));
primaryColumnCombo->setMinimumSize(secondaryColumnCombo->sizeHint());
QChar ch = first;
while (ch <= last) {
primaryColumnCombo->addItem(QString(ch));
secondaryColumnCombo->addItem(QString(ch));
tertiaryColumnCombo->addItem(QString(ch));
ch = ch.unicode() + 1;
}
}

in above code formlayout is the grid layout of the form..
I also changed my ui file as attached...
8077
Plz someone tel me what should I do to have resizable property...