dpzr52746 2019-08-26 14:17
浏览 226

在Go中运行简单的Qt GUI应用程序

I am trying to modify following simple code from here to use Qt in Go.

#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 );

    a.setMainWidget( &hello );
    hello.show();
    return a.exec();
}

My Go (Golang) code is:

package main
import (
    "github.com/therecipe/qt"
    "github.com/therecipe/qt/widgets"
)
func main() {
    a := qt.NewQApplication(len(os.Args), os.Args) //ch: widgets.NewQ..
    hello := widgets.QPushButton( "Hello world!", 0 )
    a.setMainWidget( &hello )
    hello.Show()
    a.Exec()
}

However, I get following error:

# github.com/therecipe/qt/core
core.cpp:9:30: fatal error: QAbstractAnimation: No such file or directory
 #include <QAbstractAnimation>
                              ^
compilation terminated.

I have installed Qt bindings in Go using command:

go get "github.com/therecipe/qt"

I am working on Debian9 Linux and have following Qt4 packages installed:

libntrack-qt4-1         016-1.3         016-1.3         016-1.3         install
libqt4-dev              4:4.8.7+dfsg-11 4:4.8.7+dfsg-11 4:4.8.7+dfsg-11 install
libqt4-dev-bin          4:4.8.7+dfsg-11 4:4.8.7+dfsg-11 4:4.8.7+dfsg-11 install
libqt4-opengl-dev       4:4.8.7+dfsg-11 4:4.8.7+dfsg-11 4:4.8.7+dfsg-11 install
python-qt4              4.11.4+dfsg-2+b1        4.11.4+dfsg-2+b1        4.11.4+dfsg-2+b1        install
qt4-default             4:4.8.7+dfsg-11 4:4.8.7+dfsg-11 4:4.8.7+dfsg-11 install
qt4-linguist-tools      4:4.8.7+dfsg-11 4:4.8.7+dfsg-11 4:4.8.7+dfsg-11 install
qt4-qmake               4:4.8.7+dfsg-11 4:4.8.7+dfsg-11 4:4.8.7+dfsg-11 install
ruby-qt4                4:4.14.3-1+b3   4:4.14.3-1+b3   4:4.14.3-1+b3   install

Where is the problem and how can it be solved? Thanks for your help.

Edit: For installing, I followed commands at https://github.com/therecipe/qt/wiki/Installation-on-Linux [Your system package managers version (without Android support)]. However, the command qtsetup gives following output with error:

$ sudo /home/abcde/go/bin/qtsetup
ERRO[0000] failed to run command                         _func=RunCmd cmd="go env GOMOD" dir= env= error="exec: \"go\": executable file not found in $PATH" name=GOMOD
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
    • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序