国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
QT3與QT4移植中的問題引子
Here's what I found on my Qt-4.2.2 installation (you may have to poke around to find things on your system):

Start in the qt "include" directory.On my system, is it at /usr/local/Trolltech/Qt-4.2.2/include
I'm guessing that on your system this may be /usr/include/qt4, according to the "-I..." stuff that you are seeing.

On my system there is a Qt sub-directory and there's where i see "qapplication.h". (You can go to /usr/include and run "find . -name qtapplication.h")

When I look for the text "setMainWidget" in that qtapplication.h, I see:

CPP / C++ / C Code:
#ifdef QT3_SUPPORTstatic QT3_SUPPORT QWidget *mainWidget();static QT3_SUPPORT void setMainWidget(QWidget *);#endif

So, it's telling us that something changed between Qt3 and Qt4.

For an immediate fix, you can define QT3_SUPPORT:

CPP / C++ / C Code:
//// Define QT3_SUPPORT before including any qt headers//#define QT3_SUPPORT#include <qapplication.h>#include <qpushbutton.h>int main(int argc, char **argv){


Now, try make again (no need to run qmake unless you want to).

Next step: investigate what the heck they did.

Go to the trolltech web site and look at the documentation for qapplication in qt4.2. http://doc.trolltech.com/4.2/qapplication.html

Here's the scoop:

void QApplication::setMainWidget ( QWidget * mainWidget ) [static]

Sets the application's main widget to mainWidget.

In most respects the main widget is like any other widget, except that if it is closed, the application exits. Note that QApplication does not take ownership of the mainWidget, so if you create your main widget on the heap you must delete it yourself.

You need not have a main widget; connecting lastWindowClosed() to quit() is an alternative.

For X11, this function also resizes and moves the main widget according to the -geometry command-line option, so you should set the default geometry (using QWidget::setGeometry()) before calling setMainWidget().
Huh? It indicates that there is a setMainWidget in QApplication, and no indication that it was removed. (This is the Qt-4.2 documentation, right?)

However --- it does say that "you need not have a main widget".

So, just delete the setMainWidget line in your program, and remove the QT3_SUPPORT definition while you are at it:

CPP / C++ / C Code:
#include <qapplication.h>#include <qpushbutton.h>int main(int argc, char **argv){QApplication a(argc, argv);QPushButton hello("Hello world!", 0);hello.resize(100, 30);hello.show();return a.exec();}

Now start all over and see what you get. For me, it worked. Your Mileage May Vary.

Lesson learned: When you get an example program, even from a reputable source, if it doesn't work for you, then you might discover that later revisions in the tools make earlier examples non-functional. Where was the example file that you got?

Lesson learned: Programming, like life, is an adventure. For some people the trip is more important than the destination. For others, we just want to get the job done. It's still an adventure.

In my installation, in /usr/local/Trolltech/Qt-4.2.2 there is a subdirectory of "examples" that has a lot of subdirectories with source files that work with Qt-4.2.2 (Copy them to some place where you can use them; in their original place you probably don't have write privileges anyhow.)

Regards,

Dave

Footnote:

"It's not a problem; it's an opportunity!"
--- My old pal Jorge Rivera

"I like opportunities as much as the next guy. It's
just that on Saturday afternoons I would rather
define my own adventures rather than working
on other people's opportunities (like the boss's
deadline)."
---davekw7x
  #3  
07-Mar-2007, 11:37
davis
 
Posts: n/a

Re: problem in hello world programme in qt


Quote:
Originally Posted by u04f061
i am new user of qt and i am running ubuntu dapper linux.i got this hello world programe from trolltech official site. i could not run this programe. i got an error.here it is

#include <qapplication.h>
#include <qpushbutton.h>g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o main.o main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:12: error: ‘class QApplication’ has no member named ‘setMainWidget’
make: *** [main.o] Error 1

The code is pre v4.0 and is using API from v3.x. Go to your examples directory under your /usr/share/qt4 path and try the hello from there.
本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Qt項目文件詳解
QT父子窗口事件傳遞與事件過濾器
QT起點之“Hello World”示例
QDialog、QWidget、QMainWindow的區(qū)別
Qtcreator教程二(編寫多窗口程序)
QT Embedded二三事之FAQ
更多類似文章 >>
生活服務
分享 收藏 導長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服