I'm learning with Qt and I have a question
Hello, I'm trying to learn to code something with Qt by myself, so now I have a problem:
http://edvinas.edas.lt/images/sth7c8gwsnuvm1s237.png This is what I've made, when i press next it just cleares that 'TEXT TEXT TEXT', i want to know how to make that change to 'TEXT2 TEXT2 TEXT2' and later change that to 'Whatever other text' and so on to change it to other text. Sorry my english is very bad. |
Re: I'm learning with Qt and I have a question
Are you using python or c++? If the control displaying "TEXT TEXT TEXT" in your example is a simple label and you are using c++ you should use the label->setText(const QString &text) method.
Your english is fine by the way... |
Re: I'm learning with Qt and I have a question
Well i did everything using that mainwindow.ui not coding :| I've started learning with that Qt only like 5hours ago..
And yea it's a label there |
Re: I'm learning with Qt and I have a question
In case you haven't already found out (since you are so new to Qt): Qt has very good documentation with nice examples here http://doc.trolltech.com/4.5/index.html
For example: http://doc.trolltech.com/4.5/qlabel.html |
Re: I'm learning with Qt and I have a question
omg, I didn't think that so much of everything is to make text change (I didn't make it to work yet) :O
BTW. Can u gudie me what i have to change (to make text text text to text2 text2 text2 and later to something else and so on...) and why? I would be very grateful, here's my current script: Code:
#include "mainwindow.h" |
Re: I'm learning with Qt and I have a question
Quote:
Code:
void MainWindow::on_Button_clicked() Hope this helps :) |
Re: I'm learning with Qt and I have a question
Quote:
|
Re: I'm learning with Qt and I have a question
Quote:
|
Re: I'm learning with Qt and I have a question
erm.. how do I do that?
|
Re: I'm learning with Qt and I have a question
this is telling me that QT is like a Programming language or something to do with code, strings and etc....
|
Re: I'm learning with Qt and I have a question
Quote:
Code:
class MainWindow in the first line of the file just after all the #includes define this variable, Code:
int MainWindow::_clickCounter = 0; Code:
void MainWindow::on_Button_clicked() |
Re: I'm learning with Qt and I have a question
Quote:
QT is based on C++, so if you know C++ ( even some basics ), you should feel at home. |
Re: I'm learning with Qt and I have a question
Quote:
|
Re: I'm learning with Qt and I have a question
so you want to print a random text from a list every time you click ?
whats the requirement ? |
Re: I'm learning with Qt and I have a question
Quote:
something like this: 1. Hello 2. Meow 3. Lol ...... 500. Text and i want it to show next line everytime i press next |
Re: I'm learning with Qt and I have a question
Quote:
mainwindow.h Code:
class MainWindow Code:
in the first line of the file just after all the #includes define this variable, |
Re: I'm learning with Qt and I have a question
Here's my window.h
Code:
#ifndef MAINWINDOW_H Code:
#include "mainwindow.h" |
Re: I'm learning with Qt and I have a question
Removes the brackets in line 24 and 30.
|
Re: I'm learning with Qt and I have a question
Quote:
.... private: Ui::MainWindow *ui; // member functions void MainWindow::initMyWordList() // member variables static int _clickCounter; QStringList _wordList; }; .... |
Re: I'm learning with Qt and I have a question
now it looks like that:
mainwindow.h: Code:
#ifndef MAINWINDOW_H Code:
#include <QtGui/QApplication> Code:
#include "mainwindow.h" C:/Users/Edvinas/Documents/InteractiveHelloWorld/main.cpp:2: In file included from main.cpp:2: C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.h:24: error: expected unqualified-id before '{' token C:/Users/Edvinas/Documents/InteractiveHelloWorld/main.cpp:10: error: expected unqualified-id at end of input |
Re: I'm learning with Qt and I have a question
Your curly brackets aren't matching. You can easily see that in the main.cpp where you have two closing ones right after each other.
|
Re: I'm learning with Qt and I have a question
Quote:
|
Re: I'm learning with Qt and I have a question
If I remove one i get theese errors:
C:/Users/Edvinas/Documents/InteractiveHelloWorld/main.cpp:2: In file included from main.cpp:2: C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.h:24: error: expected unqualified-id before '{' token C:/Users/Edvinas/Documents/InteractiveHelloWorld/main.cpp:10: error: expected '}' at end of input C:/Users/Edvinas/Documents/InteractiveHelloWorld/main.cpp:10: error: expected unqualified-id at end of input |
Re: I'm learning with Qt and I have a question
Anyone? :(
|
Re: I'm learning with Qt and I have a question
Quote:
and add them to: mainwindow.h Like someone said before: Compare and match the curly braces Code:
private: |
Re: I'm learning with Qt and I have a question
Quote:
Quote:
every opening bracket (curly, square, round) has to be closed again. check your ide's or editor's settings -- almost all should have some kind of visual markers helping you to detect those trivial and easily overlocked syntactical errors. |
Re: I'm learning with Qt and I have a question
Ok, now i get only this:
C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.h:11: error: expected unqualified-id before '{' token C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.h:11: error: expected unqualified-id before '{' token here's mainwindow.h: Quote:
|
Re: I'm learning with Qt and I have a question
class MainWindow : public QMainWindow;
remove the semicolon from the end of the line, you put a semicolon only when you finish a definition or statement, here the class definition isnt over. Put the semi-colon at the end of the mainwindow.h after the last curly brace marking the end of the class definition. |
Re: I'm learning with Qt and I have a question
Quote:
C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.h:26: error: extra qualification 'MainWindow::' on member 'initMyWordList' |
Re: I'm learning with Qt and I have a question
do what the error says, remove the "extra qualification 'MainWindow::' " at line 26:
void MainWindow::initMyWordList(); should be void initMyWordList(); in your header you are declaring the class itself, no need for the namespace here. |
Re: I'm learning with Qt and I have a question
:S now i get those:
C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:33: error: expected initializer before 'void' C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:41: error: declaration of 'void MainWindow::initMyWordList()' outside of class is not definition C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:42: error: expected unqualified-id before '{' token mainwindow.cpp: Quote:
|
Re: I'm learning with Qt and I have a question
Code:
void MainWindow::buttonClickHandler() Code:
void MainWindow::buttonClickHandler() Code:
do whatever you feel like Code:
// do whatever you feel like |
Re: I'm learning with Qt and I have a question
C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:35: error: no 'void MainWindow::on_Button_clicked()' member function declared in class 'MainWindow'
C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:43: error: declaration of 'void MainWindow::initMyWordList()' outside of class is not definition Then i get that :( omg so much errors |
Re: I'm learning with Qt and I have a question
Quote:
Code:
// do whatever you feel like Code:
{ } // do nothing Code:
; // do nothing |
Re: I'm learning with Qt and I have a question
When you once saw most of the errors next time you may correct them yourself. But you should learn a bit more basics of c++ so you would understand the errors.
Quote:
Code:
void On_Button_clicked(); |
Re: I'm learning with Qt and I have a question
Oh, and
Code:
error = initMyWordList(); |
Re: I'm learning with Qt and I have a question
I'm also new to Qt.
I have a simple question: How do I make a dialog window uncloseable? I mean, how to create a QDialog (or a QMessageBox) which can't be closed by the user, but only the application itself? |
Re: I'm learning with Qt and I have a question
Quote:
|
Re: I'm learning with Qt and I have a question
http://doc.trolltech.com/4.6/qwidget.html#closeEvent
Reimplement this event handler to ignore the close event on a certain condition. Also see the example which explains why this can be useful. |
Re: I'm learning with Qt and I have a question
Quote:
|
All times are GMT. The time now is 08:31. |
vBulletin® Version 3.8.8