Oops, sorry. :-P
Oops, sorry. :-P
Just GET it OFF out my mind!!
Yea, I wanted to use QT Designer, but was unable to find a place to download it from.
Supposedly, its bundled with the free edition of QT (or so said someone on their forums), but I downloaded the latest QT SDK from their site, and it didn't include QT Designer or QT Assistant.
I'm searching again right now, on Google...
EDIT:
And that's not the code I used. (I'll post the code in a few)
Last edited by Programmer_P; 08-15-2009 at 09:21 AM.
Yea, according to a post found at this link:
where can i download free qt designer? - Qt Designer - QtForum.org
its included with QT, but that is just not the case.
I had hopes the link in the second post might be where I could download it from, but it says the page does not exist...
Header:
Implementation:Code:#ifndef TTS_MOD_H #define TTS_MOD_H #include <QDialog> class QPushButton; class TextToSpeechDialog1 : public QDialog { Q_OBJECT public: TextToSpeechDialog1(QWidget* parent = 0); private slots: void nextClicked(); private: QPushButton* nextButton; }; #endif // TTS_MOD_H
Code:TextToSpeechDialog1::TextToSpeechDialog1(QWidget *parent) : QDialog(parent) { nextButton = new QPushButton(tr("&Next")); nextButton->setDefault(true); connect(nextButton, SIGNAL(clicked()), this, SLOT(nextClicked())); QHBoxLayout *bottomLayout = new QHBoxLayout; bottomLayout->addWidget(cancelButton); bottomLayout->addWidget(nextButton); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(bottomLayout); setLayout(mainLayout); setWindowTitle(tr("Text to Speech Wizard (Screen 1)")); setFixedHeight(sizeHint().height()); } void nextDialog() { TextToSpeechDialog1* p = new TextToSpeechDialog1; p->hide(); //for some reason, though I wrote this line, the first dialog is not hidden TextToSpeechDialog2* dialog2 = new TextToSpeechDialog2; dialog2->show(); } void TextToSpeechDialog1::nextClicked() { nextDialog(); //call the nextDialog() }
Download from the leftmost link, the complete SDK, not the rightmost which is only the library.
I love Qt because it is best and simple coding convention, just prefix anything with 'Q' or 'q' without any namespaces, although it isn't reusable and extensible enough to be used for big application.
Just GET it OFF out my mind!!
I did, but QT Designer was still not included in the SDK for some reason.
There is a directory in the QT/version/bin folder called "designer", but it doesn't contain the .exe.
EDIT:
Oh, and I downloaded both the Windows and Linux versions, but neither included QT Designer.
What do you mean by "big"? The application that I am writing in QT is going to be reasonably big (i'd say maybe 2,000 lines of code, not counting the included QT header files).I love Qt because it is best and simple coding convention, just prefix anything with 'Q' or 'q' without any namespaces, although it isn't reusable and extensible enough to be used for big application.
Last edited by Programmer_P; 08-15-2009 at 10:17 AM. Reason: left something out
So the dialog1 show the new dialog2 and then the dialog1 is hidden?
1. Make the dialog2 to be member of the 1 so it can be deleted.
2. Just call hide() without creating new instance.
Just GET it OFF out my mind!!
It should be in Qt/ver/qt/bin
Just GET it OFF out my mind!!
Not quite. The dialog 1 calls the global function (nextDialog()), which first hides (or is supposed to) the first dialog (through a new object of the class), and then a object of dialog 2 is created, and dialog2->show() is called, so it becomes visible. EDIT: Nevermind. Scratch that. I now see my mistake. I will need to call hide from the first instance in order to hide it, of course...it wont work from a new object.
I have thought about making 2 a derived class of 1, but then I would have to go to extra work to parse the code of 1 that i don't need in 2, and there must be a way to get it to work without that. Maybe just jump back to int main(), and call the hide function from the first instance.
Last edited by Programmer_P; 08-15-2009 at 10:45 AM.
The designer also "embedded" inside the creator, yet it can be launched inside the creator too.
About the "delete this"
Code:std::auto_ptr< YourClass<T> > thisIsUglierAndUnfrendlySyntaxYouEverUsed(void);
Just GET it OFF out my mind!!
It's not unfriendly and it's not ugly. Compare it to something like this:
void ThisIsADescriptiveFunctionName();
void TIADFN();
Which name is more descriptive here?
If I see a function returning a shared pointer, I can rest assured that I won't have to do anything special with it or handle it with care.
Also, delete this only works if it was allocated with new. And new is potentially 50x or more slower than creating the object on the stack. So why use it in the first place? Let the programmer be able to choose where to create the object.
Also, auto_ptr is possibly bad in this case since it has exclusive ownership, not shared.
Well, my last assumption was almost correct. However, since the hide function would be called without hitting the next button (due to me putting it in int main, as is), I had to think of a different method.
So what I did instead was I created a function (named sendHideReqest()) which I put the hide line in. I then simply passed "dialog" (the first dialog's class's object) into the function when I called it from int main. Unfortunately, the end result was the same.
I tried using an if statement to control when the sendHideRequest() function is called, but for some reason, it seems to call it anyway (maybe due to the nature of if statements?), even before I push the next button of the first dialog.
Here's the relevant code:
Code:int nextDialog() { TextToSpeechDialog2* dialog2 = new TextToSpeechDialog2; dialog2->show(); return 1; } void sendHideRequest(TextToSpeechDialog1* hide) { hide->hide(); //this line hides TextToSpeechDialog1 } void TextToSpeechDialog1::nextClicked() { nextDialog(); //call the nextDialog() } int main(int argc, char* argv[]) { QApplication app(argc, argv); TextToSpeechDialog1* dialog = new TextToSpeechDialog1; dialog->show(); if (nextDialog() == true) //the trouble line: it seems to by default call nextDialog() sendHideRequest(dialog); //pass the "dialog" object into the function return app.exec(); //hand control of the program over to QT }
So what happens is when the program opens, you only see the second dialog (the first dialog is already hidden). The code was supposed to wait until I press Next on the first dialog to call the second dialog (and subsequently hide the first dialog), but it seems to call nextDialog() as a result of the if line, and so the end result is only the second dialog is displayed.
But obviously, you just show the first window, then proceed to show the second window, then immediately return 1 (which really should be true and bool), and goes on to hiding the first dialog.
You need to wait for some event that indicates that the "next" button has been pressed before proceeding. How that's done in Qt, I have no idea, though.