Re: A few questoins about Qt
Quote:
Originally Posted by
HelloDan
1 By default, that's not a minimize button in the Qt widget in windows, but a help ("?" symbol) button. If I want to add a minimize button for a dialog at the same remove the help symbol. What I should do.
Qt::WindowFlags
Quote:
2 Why I write a file in the patten in a console window:
QFile file("C:\abc\test.txt");
it doesn,t work. But it work in this way : QFile file("C:\\abc\\test.txt"); At the same time, I get the file name from QFileDialog::getOpenFileName and do not need to replace '\' with "\\". and it work fine. Why?
escaping?
Re: A few questoins about Qt
Quote:
Originally Posted by
HelloDan
3 My code fragment is showed as the following:
Code:
if(cloudCheckBox->checkState()==Qt::Checked);
{
for(size_t i=9;i<17;++i)
{
trimCloud(list[i]);
}
}
It's strange that even I do not click the CheckBox, but it still execute the above code fragment. I try cloudCheckBox->isChecked() instead, I got the same result. Why?
checkState() is a state not an action. If you want react on user actions use signal and slots. (By the way, maybe you want use QAbstractButton::isChecked().)
Quote:
4 From my perspective, I do think that try my thinking in a console window is very useful. Also because that I don't know how to test my code in a GUI program, it's very trival.
How do you solve this problem?
I don't understand the question. For debugging a GUI use gdb or simple qDebug().
Re: A few questoins about Qt
qDebug().
How to use qDebug()? I try it in the console window, it's OK. But I try in a GUI program, I can see nothing.
Re: A few questoins about Qt
Add CONFIG+=console to your project file and rerun qmake.
Re: A few questoins about Qt
I don't know how to correct the cloudCheckBox->checkState()==Qt::Checked problem.
Can anyone give some tips?
Re: A few questoins about Qt
What do you want achieve? And when do you call the function which is checking the state of the box?
Re: A few questoins about Qt
I'm sorry. My English is really very limited.
What i want to achive is that if the cloudCheckBox has a "√" (it's checked.), then execute the code. otherwise, do nothing.
but the following code line seem that it always true, even i remove the "√"
if(cloudCheckBox->isChecked());
Why? how to solve the problem. Thanks!
Re: A few questoins about Qt
your constructor:
Code:
QObject::connect(cloudCheckBox,
SIGNAL(toggled
(bool)),
this,
SLOT(yourSlot
(bool));
and then
Code:
void YourClass::yourSlot(bool checked)
{
if (checked) {
// do what ever you want
}
}
Re: A few questoins about Qt
if(cloudCheckBox->checkState()==Qt::Checked);
Thank! It's a very stupid mistake. remove ; will be ok